Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c7f9bb36

Von Philip Reetz vor fast 19 Jahren hinzugefügt

  • ID c7f9bb36eb122b2d79f5aa8c4d080279705ddc7e
  • Vorgänger 59c1d7e3
  • Nachfolger b1253e4f

Buchungsjournal um Anzeige von Splitbuchungen erweitert, Splitbuchungen beim Dialogbuchen zu 80% fertig. Neue Maske fuer Splitbuchungen

Unterschiede anzeigen:

SL/GL.pm
38 38

  
39 39
package GL;
40 40

  
41
use Data::Dumper;
42

  
43 41
sub delete_transaction {
44
  $main::lxdebug->enter_sub();
45

  
46 42
  my ($self, $myconfig, $form) = @_;
47

  
43
  
48 44
  # connect to database
49 45
  my $dbh = $form->dbconnect_noauto($myconfig);
50 46

  
......
57 53
  # commit and redirect
58 54
  my $rc = $dbh->commit;
59 55
  $dbh->disconnect;
60

  
61
  $main::lxdebug->leave_sub();
62

  
63
  return $rc;
56
  
57
  $rc;
58
  
64 59
}
65 60

  
66
sub post_transaction {
67
  $main::lxdebug->enter_sub();
68 61

  
62
sub post_transaction {
69 63
  my ($self, $myconfig, $form) = @_;
70

  
64
  
71 65
  my ($debit, $credit) = (0, 0);
72 66
  my $project_id;
73 67

  
74 68
  my $i;
75

  
76 69
  # check if debit and credit balances
77

  
78
  $debit  = abs(int($form->round_amount($form->{debit},  3) * 1000));
79
  $credit = abs(int($form->round_amount($form->{credit}, 3) * 1000));
80
  $tax    = abs(int($form->round_amount($form->{tax},    3) * 1000));
81

  
82
  if (   (($debit >= $credit) && (abs($debit - ($credit + $tax)) > 4))
83
      || (($debit < $credit) && (abs(($debit + $tax) - $credit) > 4))) {
84
    return -2;
85
  }
86

  
87
  if (($debit + $credit + $tax) == 0) {
88
    return -3;
89
  }
90

  
91
  $debit  = $form->round_amount($form->{debit},  2);
92
  $credit = $form->round_amount($form->{credit}, 2);
93
  $tax    = $form->round_amount($form->{tax},    2);
94
  debug($debit, $credit, $tax, "Betraege");
95

  
70
  
96 71
  if ($form->{storno}) {
97
    $debit               = $debit * -1;
98
    $credit              = $credit * -1;
99
    $tax                 = $tax * -1;
100
    $form->{reference}   = "Storno-" . $form->{reference};
101
    $form->{description} = "Storno-" . $form->{description};
102
  }
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
  }  
103 78

  
104 79
  # connect to database, turn off AutoCommit
105 80
  my $dbh = $form->dbconnect_noauto($myconfig);
......
119 94
  if (!$form->{taxincluded}) {
120 95
    $form->{taxincluded} = 0;
121 96
  }
122

  
97
  
123 98
  my ($query, $sth);
99
  
124 100
  if ($form->{id}) {
125

  
126 101
    # delete individual transactions
127
    $query = qq|DELETE FROM acc_trans
102
    $query = qq|DELETE FROM acc_trans 
128 103
                WHERE trans_id = $form->{id}|;
129 104
    $dbh->do($query) || $form->dberror($query);
130

  
105
    
131 106
  } else {
132 107
    my $uid = time;
133 108
    $uid .= $form->{login};
......
136 111
                VALUES ('$uid', (SELECT e.id FROM employee e
137 112
		                 WHERE e.login = '$form->{login}'))|;
138 113
    $dbh->do($query) || $form->dberror($query);
139

  
114
    
140 115
    $query = qq|SELECT g.id FROM gl g
141 116
                WHERE g.reference = '$uid'|;
142 117
    $sth = $dbh->prepare($query);
......
146 121
    $sth->finish;
147 122

  
148 123
  }
124
  
149 125
  my ($null, $department_id) = split /--/, $form->{department};
150 126
  $department_id *= 1;
151

  
152
  $query = qq|UPDATE gl SET
127
  
128
  $query = qq|UPDATE gl SET 
153 129
	      reference = '$form->{reference}',
154 130
	      description = '$form->{description}',
155 131
	      notes = '$form->{notes}',
......
157 133
	      department_id = $department_id,
158 134
	      taxincluded = '$form->{taxincluded}'
159 135
	      WHERE id = $form->{id}|;
160

  
136
	   
161 137
  $dbh->do($query) || $form->dberror($query);
162 138
  ($taxkey, $rate) = split(/--/, $form->{taxkey});
163 139

  
164
  # insert acc_trans transactions
165
  foreach $i ((credit, debit)) {
166 140

  
141
  # insert acc_trans transactions
142
  for $i (1 .. $form->{rowcount}) {
167 143
    # extract accno
168
    ($accno) = split(/--/, $form->{"${i}chartselected"});
144
    my ($accno) = split(/--/, $form->{"accno_$i"});
145
    my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
169 146
    my $amount = 0;
170
    debug("$accno $i Kontonummer");
171
    if ($i eq "credit") {
147
    my $debit = $form->{"debit_$i"};
148
    my $credit = $form->{"credit_$i"};
149
    my $tax = $form->{"tax_$i"};
150
    
151
    if ($credit) {
172 152
      $amount = $credit;
153
      $posted = 0;
173 154
    }
174
    if ($i eq "debit") {
155
    if ($debit) {
175 156
      $amount = $debit * -1;
157
      $tax = $tax * -1;
158
      $posted = 0;
176 159
    }
177 160

  
178
    if ($form->{"${i}_splited"}) {
179

  
180
      # if there is an amount, add the record
181
      for $j (2 .. $form->{"${i}rowcount"}) {
182
        ($accno) = split(/--/, $form->{"${i}chartselected_$j"});
183

  
184
        $amount = $form->{"${i}_$j"};
185

  
186
        ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$j"});
187

  
188
        if ($i eq "debit") {
189
          $amount *= -1;
190
        }
191
        if ($amount != 0) {
192
          $project_id =
193
            ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
194
          $query =
195
            qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
196
                      source, project_id, taxkey)
197
                      VALUES
198
                      ($form->{id}, (SELECT c.id
199
                                    FROM chart c
200
                                    WHERE c.accno = '$accno'),
201
                      $amount, '$form->{transdate}', '$form->{reference}',
202
                      $project_id, $taxkey)|;
203

  
204
          $dbh->do($query) || $form->dberror($query);
205
        }
206

  
207
        $tax = $form->{"tax_$j"};
208
        print(STDERR $tax, " Steuer bei Durchlauf $j\n\n");
209
        if ($tax != 0) {
210 161

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

  
217
          $project_id =
218
            ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
219
          $query =
220
            qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
221
                    source, project_id, taxkey)
222
                    VALUES
223
                    ($form->{id}, (SELECT t.chart_id
224
                    FROM tax t
225
                    WHERE t.taxkey = $taxkey),
226
                    $amount, '$form->{transdate}', '$form->{reference}',
227
                            $project_id, $taxkey)|;
228

  
229
          $dbh->do($query) || $form->dberror($query);
230
        }
231
      }
232
    } else {
233

  
234
      # if there is an amount, add the record
235
      ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected"});
236
      $taxkey *= 1;
237
      debug("$amount auf $accno buchen");
238
      if ($amount != 0) {
239
        $project_id =
240
          ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
241
        $query =
242
          qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
243
                      source, project_id, taxkey)
244
                      VALUES
245
                      ($form->{id}, (SELECT c.id
246
                                    FROM chart c
247
                                    WHERE c.accno = '$accno'),
248
                      $amount, '$form->{transdate}', '$form->{reference}',
249
                      $project_id, $taxkey)|;
250

  
251
        $dbh->do($query) || $form->dberror($query);
252
      }
253
    }
254
  }
255
  if ($tax != 0 && !($form->{credit_splited} || $form->{debit_splited})) {
256

  
257
    # add taxentry
258
    if ($form->{debittaxkey}) {
259
      $tax = $tax * (-1);
260
    }
261
    $amount = $tax;
262
    debug("$amount Steuern buchen");
263

  
264
    $project_id =
265
      ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
266
    $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
267
                  source, project_id, taxkey)
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,
186
                  source, memo, project_id, taxkey)
268 187
                  VALUES
269 188
                  ($form->{id}, (SELECT t.chart_id
270 189
                  FROM tax t
271 190
                  WHERE t.taxkey = $taxkey),
272
                  $amount, '$form->{transdate}', '$form->{reference}',
191
                  $amount, '$form->{transdate}', |.
192
		   $dbh->quote($form->{"source_$i"}) .qq|, |.
193
		  $dbh->quote($form->{"memo_$i"}).qq|,
273 194
                          $project_id, $taxkey)|;
274

  
275
    $dbh->do($query) || $form->dberror($query);
195
          
196
          $dbh->do($query) || $form->dberror($query);
197
    }
276 198
  }
277 199

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

  
278 208
  # commit and redirect
279 209
  my $rc = $dbh->commit;
280 210
  $dbh->disconnect;
281 211

  
282
  $main::lxdebug->leave_sub();
212
  $rc;
283 213

  
284
  return $rc;
285 214
}
286 215

  
287
sub all_transactions {
288
  $main::lxdebug->enter_sub();
289 216

  
217

  
218
sub all_transactions {
290 219
  my ($self, $myconfig, $form) = @_;
291 220

  
292 221
  # connect to database
......
294 223
  my ($query, $sth, $source, $null);
295 224

  
296 225
  my ($glwhere, $arwhere, $apwhere) = ("1 = 1", "1 = 1", "1 = 1");
297

  
226
  
298 227
  if ($form->{reference}) {
299 228
    $source = $form->like(lc $form->{reference});
300 229
    $glwhere .= " AND lower(g.reference) LIKE '$source'";
......
353 282
  }
354 283

  
355 284
  if ($form->{accno}) {
356

  
357 285
    # get category for account
358 286
    $query = qq|SELECT c.category
359 287
                FROM chart c
360 288
		WHERE c.accno = '$form->{accno}'|;
361
    $sth = $dbh->prepare($query);
362

  
363
    $sth->execute || $form->dberror($query);
364
    ($form->{ml}) = $sth->fetchrow_array;
365
    $sth->finish;
289
    $sth = $dbh->prepare($query); 
366 290

  
291
    $sth->execute || $form->dberror($query); 
292
    ($form->{ml}) = $sth->fetchrow_array; 
293
    $sth->finish; 
294
    
367 295
    if ($form->{datefrom}) {
368 296
      $query = qq|SELECT SUM(ac.amount)
369 297
		  FROM acc_trans ac, chart c
......
378 306
      $sth->finish;
379 307
    }
380 308
  }
381

  
309
  
382 310
  if ($form->{gifi_accno}) {
383

  
384 311
    # get category for account
385 312
    $query = qq|SELECT c.category
386 313
                FROM chart c
387 314
		WHERE c.gifi_accno = '$form->{gifi_accno}'|;
388
    $sth = $dbh->prepare($query);
389

  
390
    $sth->execute || $form->dberror($query);
391
    ($form->{ml}) = $sth->fetchrow_array;
392
    $sth->finish;
315
    $sth = $dbh->prepare($query); 
393 316

  
317
    $sth->execute || $form->dberror($query); 
318
    ($form->{ml}) = $sth->fetchrow_array; 
319
    $sth->finish; 
320
   
394 321
    if ($form->{datefrom}) {
395 322
      $query = qq|SELECT SUM(ac.amount)
396 323
		  FROM acc_trans ac, chart c
......
406 333
    }
407 334
  }
408 335

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

  
411
  my $query =
412
    qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
338
  
339
  my $query = qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
413 340
                 g.description, ac.transdate, ac.source, ac.trans_id,
414 341
		 ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
415 342
                 FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON
......
440 367
	         ORDER BY transdate, trans_id, taxkey DESC, sorttax DESC, oid|;
441 368
  my $sth = $dbh->prepare($query);
442 369
  $sth->execute || $form->dberror($query);
443

  
370
  
444 371
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
445 372
    print(STDERR $ref->{id}, " Transaction\n");
446

  
447 373
    # gl
448 374
    if ($ref->{type} eq "gl") {
449 375
      $ref->{module} = "gl";
......
466 392
        $ref->{module} = "ar";
467 393
      }
468 394
    }
469
    $balance = $ref->{amount};
470
    $i       = 0;
471
    $j       = 0;
472
    $k       = 0;
473
    $l       = 0;
395
    $balance=$ref->{amount};
396
    $i = 0;
397
    $j = 0;
398
    $k = 0;
399
    $l = 0;
474 400
    if ($ref->{amount} < 0) {
475
      if ($ref->{chart_id} > 0) {
476
        $ref->{debit_tax}{$i}       = $ref->{amount} * -1;
401
      if ($ref->{chart_id} >0) {
402
        $ref->{debit_tax}{$i} = $ref->{amount} * -1;
477 403
        $ref->{debit_tax_accno}{$i} = $ref->{accno};
478
      } else {
479
        $ref->{debit}{$k}        = $ref->{amount} * -1;
480
        $ref->{debit_accno}{$k}  = $ref->{accno};
404
        }
405
      else {
406
        $ref->{debit}{$k} = $ref->{amount} * -1;
407
        $ref->{debit_accno}{$k} = $ref->{accno};
481 408
        $ref->{debit_taxkey}{$k} = $ref->{taxkey};
482
      }
409
        }
483 410
    } else {
484
      if ($ref->{chart_id} > 0) {
485
        $ref->{credit_tax}{$j}       = $ref->{amount};
411
      if ($ref->{chart_id} >0) {
412
        $ref->{credit_tax}{$j} = $ref->{amount};
486 413
        $ref->{credit_tax_accno}{$j} = $ref->{accno};
487
      } else {
488
        $ref->{credit}{$l}        = $ref->{amount};
489
        $ref->{credit_accno}{$l}  = $ref->{accno};
414
        }
415
      else {
416
        $ref->{credit}{$l} = $ref->{amount};
417
        $ref->{credit_accno}{$l} = $ref->{accno};
490 418
        $ref->{credit_taxkey}{$l} = $ref->{taxkey};
491
      }
419
        }
492 420
    }
493 421

  
494
    while (abs($balance) >= 0.015) {
495
      my $ref2 = $sth->fetchrow_hashref(NAME_lc)
496
        || $form->error("Unbalanced ledger!");
422
    while (abs($balance)>=0.015) {
423
      my $ref2 = $sth->fetchrow_hashref(NAME_lc) || $form->error("Unbalanced ledger!");
497 424

  
498
      $balance =
499
        (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
500
      print(STDERR $balance, " BAlance\n");
425
      $balance = (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
426
      print(STDERR $balance," BAlance\n");
501 427
      if ($ref2->{amount} < 0) {
502
        if ($ref2->{chart_id} > 0) {
428
        if ($ref2->{chart_id} >0) {
503 429
          if ($ref->{debit_tax_accno}{$i} ne "") {
504 430
            $i++;
505 431
          }
506
          $ref->{debit_tax}{$i}       = $ref2->{amount} * -1;
432
          $ref->{debit_tax}{$i} = $ref2->{amount} * -1;
507 433
          $ref->{debit_tax_accno}{$i} = $ref2->{accno};
508
        } else {
434
          }
435
        else {
509 436
          if ($ref->{debit_accno}{$k} ne "") {
510 437
            $k++;
511 438
          }
512
          $ref->{debit}{$k}        = $ref2->{amount} * -1;
513
          $ref->{debit_accno}{$k}  = $ref2->{accno};
439
          $ref->{debit}{$k} = $ref2->{amount} * -1;
440
          $ref->{debit_accno}{$k} = $ref2->{accno};
514 441
          $ref->{debit_taxkey}{$k} = $ref2->{taxkey};
515
        }
442
          }
516 443
      } else {
517
        if ($ref2->{chart_id} > 0) {
444
        if ($ref2->{chart_id} >0) {
518 445
          if ($ref->{credit_tax_accno}{$j} ne "") {
519 446
            $j++;
520 447
          }
521
          $ref->{credit_tax}{$j}       = $ref2->{amount};
448
          $ref->{credit_tax}{$j} = $ref2->{amount};
522 449
          $ref->{credit_tax_accno}{$j} = $ref2->{accno};
523
        } else {
450
          }
451
        else {
524 452
          if ($ref->{credit_accno}{$l} ne "") {
525 453
            $l++;
526 454
          }
527
          $ref->{credit}{$l}        = $ref2->{amount};
528
          $ref->{credit_accno}{$l}  = $ref2->{accno};
455
          $ref->{credit}{$l} = $ref2->{amount};
456
          $ref->{credit_accno}{$l} = $ref2->{accno};
529 457
          $ref->{credit_taxkey}{$l} = $ref2->{taxkey};
530
        }
458
          }
531 459
      }
532 460
    }
533

  
534
    #    print(STDERR Dumper($ref));
461
#    print(STDERR Dumper($ref));       
535 462
    push @{ $form->{GL} }, $ref;
536
    $balance = 0;
463
    $balance=0;
537 464
  }
538 465
  $sth->finish;
539 466

  
540 467
  if ($form->{accno}) {
541
    $query =
542
      qq|SELECT c.description FROM chart c WHERE c.accno = '$form->{accno}'|;
468
    $query = qq|SELECT c.description FROM chart c WHERE c.accno = '$form->{accno}'|;
543 469
    $sth = $dbh->prepare($query);
544 470
    $sth->execute || $form->dberror($query);
545 471

  
......
547 473
    $sth->finish;
548 474
  }
549 475
  if ($form->{gifi_accno}) {
550
    $query =
551
      qq|SELECT g.description FROM gifi g WHERE g.accno = '$form->{gifi_accno}'|;
476
    $query = qq|SELECT g.description FROM gifi g WHERE g.accno = '$form->{gifi_accno}'|;
552 477
    $sth = $dbh->prepare($query);
553 478
    $sth->execute || $form->dberror($query);
554 479

  
555 480
    ($form->{gifi_account_description}) = $sth->fetchrow_array;
556 481
    $sth->finish;
557 482
  }
558

  
483
 
559 484
  $dbh->disconnect;
560 485

  
561
  $main::lxdebug->leave_sub();
562 486
}
563 487

  
564
sub transaction {
565
  $main::lxdebug->enter_sub();
566 488

  
489
sub transaction {
567 490
  my ($self, $myconfig, $form) = @_;
568

  
491
  
569 492
  my ($query, $sth, $ref);
570

  
493
  
571 494
  # connect to database
572 495
  my $dbh = $form->dbconnect($myconfig);
573
  $form->{creditrowcount} = 1;
574
  $form->{debitrowcount}  = 1;
496

  
575 497
  if ($form->{id}) {
576 498
    $query = "SELECT closedto, revtrans
577 499
              FROM defaults";
......
584 506
    $query = "SELECT g.reference, g.description, g.notes, g.transdate,
585 507
              d.description AS department, e.name as employee, g.taxincluded, g.gldate
586 508
              FROM gl g
587
	    LEFT JOIN department d ON (d.id = g.department_id)
588
	    LEFT JOIN employee e ON (e.id = g.employee_id)
509
	    LEFT JOIN department d ON (d.id = g.department_id)  
510
	    LEFT JOIN employee e ON (e.id = g.employee_id)  
589 511
	    WHERE g.id = $form->{id}";
590 512
    $sth = $dbh->prepare($query);
591 513
    $sth->execute || $form->dberror($query);
592 514
    $ref = $sth->fetchrow_hashref(NAME_lc);
593 515
    map { $form->{$_} = $ref->{$_} } keys %$ref;
594 516
    $sth->finish;
595

  
517
  
596 518
    # retrieve individual rows
597 519
    $query = "SELECT c.accno, a.amount, project_id,
598 520
                (SELECT p.projectnumber FROM project p
......
600 522
	      FROM acc_trans a, chart c
601 523
	      WHERE a.chart_id = c.id
602 524
	      AND a.trans_id = $form->{id}
603
	      ORDER BY accno";
525
	      ORDER BY a.oid";
604 526
    $sth = $dbh->prepare($query);
605 527
    $sth->execute || $form->dberror($query);
606

  
607
    $debitcount  = 2;
608
    $creditcount = 2;
609
    $taxcount    = 2;
528
    
610 529
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
611

  
612
      if ($ref->{accno} eq $ref->{taxaccno}) {
613
        $form->{"tax_$taxcount"} = $ref->{amount};
614
        $form->{"tax"} += $ref->{amount};
615
        $form->{"taxchartselected_$taxcount"} = $ref->{taxkey};
616
        $taxcount++;
617
      } else {
618

  
619
        if ($ref->{amount} < 0) {
620
          $form->{"debit_$debitcount"} = $ref->{amount} * -1;
621
          $form->{"debit"} += $ref->{amount} * -1;
622
          $form->{"debitchartselected_$debitcount"} = $ref->{accno};
623
          $debitcount++;
624
        }
625
        if ($ref->{amount} > 0) {
626

  
627
          $form->{"credit_$creditcount"} = $ref->{amount};
628
          $form->{"credit"} += $ref->{amount};
629
          $form->{"creditchartselected_$creditcount"} = $ref->{accno};
630
          $creditcount++;
631
        }
632
      }
633

  
634
      $taxkey = $ref->{taxkey} * 1;
635
    }
636
    if ($creditcount > 3) {
637
      $form->{credit_splited} = 1;
638
      $form->{credit}         = $form->{credit} + $form->{tax};
639
      $form->{creditrowcount} = $creditcount - 1;
640
    } else {
641
      $form->{credit}      = $form->{credit_2};
642
      $form->{amount}      = $form->{amount_2};
643
      $form->{creditaccno} = $form->{creditchartselected_2};
644
    }
645
    if ($debitcount > 3) {
646
      $form->{debit_splited} = 1;
647
      $form->{debit}         = $form->{debit} + $form->{tax};
648
      $form->{debitrowcount} = $debitcount - 1;
649
    } else {
650
      $form->{debit}      = $form->{debit_2};
651
      $form->{debitaccno} = $form->{debitchartselected_2};
652
    }
653

  
654
    if (   (($form->{credit} > $form->{debit}) && (!$form->{taxincluded}))
655
        || (($form->{credit} > $form->{debit}) && ($form->{taxincluded}))) {
656
      $form->{amount} = $form->{debit};
657
        } else {
658
      $form->{amount} = $form->{credit};
530
      push @{ $form->{GL} }, $ref;
659 531
    }
660 532

  
661
    # get tax description
533
      # get tax description
662 534
    $query = qq| SELECT * FROM tax t|;
663
    $sth   = $dbh->prepare($query);
664
    $sth->execute || $form->dberror($query);
535
    $sth = $dbh->prepare($query);
536
    $sth->execute || $form->dberror($query);  
665 537
    $form->{TAX} = ();
666 538
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
667 539
      push @{ $form->{TAX} }, $ref;
668 540
    }
669

  
541
  
670 542
    $sth->finish;
671 543
  } else {
672 544
    $query = "SELECT current_date AS transdate, closedto, revtrans
......
674 546
    $sth = $dbh->prepare($query);
675 547
    $sth->execute || $form->dberror($query);
676 548

  
677
    ($form->{transdate}, $form->{closedto}, $form->{revtrans}) =
678
      $sth->fetchrow_array;
679

  
680
    # get tax description
549
    ($form->{transdate}, $form->{closedto}, $form->{revtrans}) = $sth->fetchrow_array;
550
    
551
      # get tax description
681 552
    $query = qq| SELECT * FROM tax t order by t.taxkey|;
682
    $sth   = $dbh->prepare($query);
683
    $sth->execute || $form->dberror($query);
553
    $sth = $dbh->prepare($query);
554
    $sth->execute || $form->dberror($query);  
684 555
    $form->{TAX} = ();
685 556
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
686 557
      push @{ $form->{TAX} }, $ref;
......
701 572
    push @{ $form->{chart} }, $ref;
702 573
  }
703 574
  $sth->finish;
575
  
704 576

  
577
  
705 578
  $sth->finish;
706

  
579
  
707 580
  $dbh->disconnect;
708 581

  
709
  $main::lxdebug->leave_sub();
710 582
}
711 583

  
712
sub debug {
713
  local *OUT;
714
  if (open(OUT, ">>/tmp/linet.log")) {
715

  
716
    #    chomp(@_);
717
    print(OUT join("\n", @_), "\n");
718
    close(OUT);
719
  } else {
720
    print(STDERR "noe: $!\n");
721
  }
722
}
723 584

  
724 585
1;
586

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

  
34

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

  
37
use Data::Dumper;
38

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

  
41 40
1;
42

  
43 41
# end of main
44 42

  
43

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

  
72

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

  
76 75
  $form->{title} = "Add";
77

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

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

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

  
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
  
95 85
  $form->{chart} = $chart;
86
  $form->{chartinit} = $chart;
87
  $form->{rowcount} = 2;
96 88

  
97
  $form->{debitchart}  = $chart;
89
  $form->{debitchart} = $chart;
98 90
  $form->{creditchart} = $chart;
99
  $form->{taxchart}    = $tax;
100

  
101
  $form->{debit}  = 0;
91
  $form->{taxchart} = $tax;
92
  
93
  $form->{debit} = 0;
102 94
  $form->{credit} = 0;
103
  $form->{tax}    = 0;
104

  
105
  $form->{creditrowcount} = 2;
106
  $form->{debitrowcount}  = 2;
95
  $form->{tax} = 0;
96
  
107 97

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

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

  
119
  &display_form;
120

  
121
  $lxdebug->leave_sub();
105
 
106
  &display_form(1);
107
  
122 108
}
123 109

  
110

  
124 111
sub edit {
125
  $lxdebug->enter_sub();
126 112

  
127 113
  GL->transaction(\%myconfig, \%$form);
128 114

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

  
147
  if ($form->{creditrowcount} > 2) {
148
    for $i (2 .. $form->{creditrowcount}) {
149
      map {
150
        if ($form->{"creditchartselected_$i"} eq $_->{accno}) {
151
          $form->{"creditchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}";
152
        }
153
      } @{ $form->{chart} };
154
      map {
155
        if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) {
156
          $form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}";
157
        }
158
      } @{ $form->{TAX} };
159
    }
160
  }
161
  if ($form->{debitrowcount} > 2) {
162
    for $i (2 .. $form->{debitrowcount}) {
163
      map {
164
        if ($form->{"debitchartselected_$i"} eq $_->{accno}) {
165
          $form->{"debitchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}";
166
        }
167
      } @{ $form->{chart} };
168
      map {
169
        if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) {
170
          $form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}";
171
        }
172
      } @{ $form->{TAX} };
173
    }
174
  }
175
  map {
176
    $chart .=
177
      "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
178
  } @{ $form->{chart} };
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
  
179 119
  $form->{chart} = $chart;
180
  map {
181
    $tax .=
182
      qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription}  |
183
      . ($_->{rate} * 100) . qq| %|
184
  } @{ $form->{TAX} };
185
  $form->{taxchart} = $tax;
186 120

  
121
  $form->{taxchart} = $tax;
122
  
187 123
  if ($form->{tax} < 0) {
188 124
    $form->{tax} = $form->{tax} * (-1);
189 125
  }
190

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

  
126
  
127
  $form->{amount}=$form->format_amount(\%myconfig, $form->{amount}, 2);
128
  
193 129
  # departments
194 130
  $form->all_departments(\%myconfig);
195 131
  if (@{ $form->{all_departments} }) {
196 132
    $form->{selectdepartment} = "<option>\n";
197 133

  
198
    map {
199
      $form->{selectdepartment} .=
200
        "<option>$_->{description}--$_->{id}\n"
201
    } (@{ $form->{all_departments} });
134
    map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
202 135
  }
203 136

  
204
  $form->{locked} =
205
    ($form->datetonum($form->{transdate}, \%myconfig) <=
206
     $form->datetonum($form->{closedto}, \%myconfig));
137
   $i = 1;
138
  foreach $ref (@{ $form->{GL} }) {
139
    $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}";
140

  
141
    $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
142
    for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
143
    
144
    if ($ref->{amount} < 0) {
145
      $form->{totaldebit} -= $ref->{amount};
146
      $form->{"debit_$i"} = $ref->{amount} * -1;
147
    } else {
148
      $form->{totalcredit} += $ref->{amount};
149
      $form->{"credit_$i"} = $ref->{amount};
150
    }
207 151

  
208
  $form->{title} = "Edit";
152
    $i++;
153
  }
209 154

  
210
  &form_header;
155
  $form->{rowcount} = $i;
156
  $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
211 157

  
158
  $form->{title} = "Edit";
159
  
160
  &form_header;
161
  &display_rows;
212 162
  &form_footer;
213

  
214
  $lxdebug->leave_sub();
163
  
215 164
}
216 165

  
166

  
167

  
217 168
sub search {
218
  $lxdebug->enter_sub();
219 169

  
220 170
  $form->{title} = $locale->text('Buchungsjournal');
221

  
171
  
222 172
  $form->all_departments(\%myconfig);
223

  
224 173
  # departments
225 174
  if (@{ $form->{all_departments} }) {
226 175
    $form->{selectdepartment} = "<option>\n";
227 176

  
228
    map {
229
      $form->{selectdepartment} .=
230
        "<option>$_->{description}--$_->{id}\n"
231
    } (@{ $form->{all_departments} });
177
    map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
232 178
  }
233

  
179
 
234 180
  $department = qq|
235 181
  	<tr>
236
	  <th align=right nowrap>| . $locale->text('Department') . qq|</th>
182
	  <th align=right nowrap>|.$locale->text('Department').qq|</th>
237 183
	  <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
238 184
	</tr>
239 185
| if $form->{selectdepartment};
240

  
186
  
241 187
  # use JavaScript Calendar or not
242 188
  $form->{jsscript} = $jscalendar;
243 189
  $jsscript = "";
244
  if ($form->{jsscript}) {
245

  
190
  if ($form->{jsscript}) 
191
  {
246 192
    # with JavaScript Calendar
247 193
    $button1 = qq|
248 194
       <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
249
       <input type=button name=datefrom id="trigger1" value=|
250
      . $locale->text('button')
251
      . qq|></td>
195
       <input type=button name=datefrom id="trigger1" value=|.$locale->text('button').qq|></td>  
252 196
       |;
253
    $button2 = qq|
197
     $button2 = qq|
254 198
       <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
255
       <input type=button name=dateto id="trigger2" value=|
256
      . $locale->text('button')
257
      . qq|></td>
199
       <input type=button name=dateto id="trigger2" value=|.$locale->text('button').qq|></td>
258 200
     |;
259

  
260
    #write Trigger
261
    $jsscript =
262
      Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
263
                          "dateto", "BL", "trigger2");
264
  } else {
265

  
266
    # without JavaScript Calendar
267
    $button1 =
268
      qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
269
    $button2 =
270
      qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
271
  }
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
    }
272 210

  
273 211
  $form->header;
274 212

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

  
378 313
<br>
379
<input class=submit type=submit name=action value="|
380
    . $locale->text('Continue') . qq|">
314
<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
381 315
</form>
382 316

  
383 317
</body>
384 318
</html>
385 319
|;
386
  $lxdebug->leave_sub();
387 320
}
388 321

  
322

  
389 323
sub generate_report {
390
  $lxdebug->enter_sub();
391 324

  
392 325
  $form->{sort} = "transdate" unless $form->{sort};
393 326

  
394 327
  GL->all_transactions(\%myconfig, \%$form);
395

  
396
  $callback =
397
    "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
328
  
329
  $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
398 330

  
399 331
  $href = $callback;
400

  
401
  %acctype = ('A' => $locale->text('Asset'),
402
              'C' => $locale->text('Contra'),
403
              'L' => $locale->text('Liability'),
404
              'Q' => $locale->text('Equity'),
405
              'I' => $locale->text('Revenue'),
406
              'E' => $locale->text('Expense'),);
407

  
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
  
408 341
  $form->{title} = $locale->text('General Ledger');
409

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

  
412 345
  unless ($form->{category} eq 'X') {
413
    $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
346
    $form->{title} .= " : ".$locale->text($acctype{$form->{category}});
414 347
  }
415 348
  if ($form->{accno}) {
416
    $href .= "&accno=" . $form->escape($form->{accno});
417
    $callback .= "&accno=" . $form->escape($form->{accno}, 1);
418
    $option =
419
      $locale->text('Account')
420
      . " : $form->{accno} $form->{account_description}";
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}";
421 352
  }
422 353
  if ($form->{gifi_accno}) {
423
    $href     .= "&gifi_accno=" . $form->escape($form->{gifi_accno});
424
    $callback .= "&gifi_accno=" . $form->escape($form->{gifi_accno}, 1);
425
    $option   .= "\n<br>" if $option;
426
    $option   .=
427
      $locale->text('GIFI')
428
      . " : $form->{gifi_accno} $form->{gifi_account_description}";
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}";
429 358
  }
430 359
  if ($form->{source}) {
431
    $href     .= "&source=" . $form->escape($form->{source});
432
    $callback .= "&source=" . $form->escape($form->{source}, 1);
433
    $option   .= "\n<br>" if $option;
434
    $option   .= $locale->text('Source') . " : $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}";
435 364
  }
436 365
  if ($form->{reference}) {
437
    $href     .= "&reference=" . $form->escape($form->{reference});
438
    $callback .= "&reference=" . $form->escape($form->{reference}, 1);
439
    $option   .= "\n<br>" if $option;
440
    $option   .= $locale->text('Reference') . " : $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}";
441 370
  }
442 371
  if ($form->{department}) {
443
    $href .= "&department=" . $form->escape($form->{department});
444
    $callback .= "&department=" . $form->escape($form->{department}, 1);
372
    $href .= "&department=".$form->escape($form->{department});
373
    $callback .= "&department=".$form->escape($form->{department},1);
445 374
    ($department) = split /--/, $form->{department};
446 375
    $option .= "\n<br>" if $option;
447
    $option .= $locale->text('Department') . " : $department";
376
    $option .= $locale->text('Department')." : $department";
448 377
  }
449 378

  
450 379
  if ($form->{description}) {
451
    $href     .= "&description=" . $form->escape($form->{description});
452
    $callback .= "&description=" . $form->escape($form->{description}, 1);
453
    $option   .= "\n<br>" if $option;
454
    $option   .= $locale->text('Description') . " : $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}";
455 384
  }
456 385
  if ($form->{notes}) {
457
    $href     .= "&notes=" . $form->escape($form->{notes});
458
    $callback .= "&notes=" . $form->escape($form->{notes}, 1);
459
    $option   .= "\n<br>" if $option;
460
    $option   .= $locale->text('Notes') . " : $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}";
461 390
  }
462

  
391
   
463 392
  if ($form->{datefrom}) {
464
    $href     .= "&datefrom=$form->{datefrom}";
393
    $href .= "&datefrom=$form->{datefrom}";
465 394
    $callback .= "&datefrom=$form->{datefrom}";
466
    $option   .= "\n<br>" if $option;
467
    $option   .=
468
        $locale->text('From') . " "
469
      . $locale->date(\%myconfig, $form->{datefrom}, 1);
395
    $option .= "\n<br>" if $option;
396
    $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{datefrom}, 1);
470 397
  }
471 398
  if ($form->{dateto}) {
472
    $href     .= "&dateto=$form->{dateto}";
399
    $href .= "&dateto=$form->{dateto}";
473 400
    $callback .= "&dateto=$form->{dateto}";
474 401
    if ($form->{datefrom}) {
475 402
      $option .= " ";
476 403
    } else {
477 404
      $option .= "\n<br>" if $option;
478 405
    }
479
    $option .=
480
        $locale->text('Bis') . " "
481
      . $locale->date(\%myconfig, $form->{dateto}, 1);
406
    $option .= $locale->text('Bis')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
482 407
  }
483 408

  
484
  @columns =
485
    $form->sort_columns(
486
    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)
487
    );
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));
488 411

  
489 412
  if ($form->{accno} || $form->{gifi_accno}) {
490 413
    @columns = grep !/(accno|gifi_accno)/, @columns;
491 414
    push @columns, "balance";
492 415
    $form->{l_balance} = "Y";
493

  
494
  }
495

  
496
  $form->{l_credit_accno}     = "Y";
497
  $form->{l_debit_accno}      = "Y";
498
  $form->{l_credit_tax}       = "Y";
499
  $form->{l_debit_tax}        = "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";
500 423
  $form->{l_credit_tax_accno} = "Y";
501
  $form->{l_debit_tax_accno}  = "Y";
502
  $form->{l_accno}            = "N";
424
  $form->{l_debit_tax_accno} = "Y";
425
  $form->{l_accno} = "N";
503 426
  foreach $item (@columns) {
504 427
    if ($form->{"l_$item"} eq "Y") {
505 428
      push @column_index, $item;
506 429

  
507 430
      # add column to href and callback
508 431
      $callback .= "&l_$item=Y";
509
      $href     .= "&l_$item=Y";
432
      $href .= "&l_$item=Y";
510 433
    }
511 434
  }
512 435

  
513 436
  if ($form->{l_subtotal} eq 'Y') {
514 437
    $callback .= "&l_subtotal=Y";
515
    $href     .= "&l_subtotal=Y";
438
    $href .= "&l_subtotal=Y";
516 439
  }
517 440

  
518 441
  $callback .= "&category=$form->{category}";
519
  $href     .= "&category=$form->{category}";
520

  
521
  $column_header{id} =
522
      "<th><a class=listheading href=$href&sort=id>"
523
    . $locale->text('ID')
524
    . "</a></th>";
525
  $column_header{transdate} =
526
      "<th><a class=listheading href=$href&sort=transdate>"
527
    . $locale->text('Date')
528
    . "</a></th>";
529
  $column_header{reference} =
530
      "<th><a class=listheading href=$href&sort=reference>"
531
    . $locale->text('Reference')
532
    . "</a></th>";
533
  $column_header{source} =
534
      "<th><a class=listheading href=$href&sort=source>"
535
    . $locale->text('Source')
536
    . "</a></th>";
537
  $column_header{description} =
538
      "<th><a class=listheading href=$href&sort=description>"
539
    . $locale->text('Description')
540
    . "</a></th>";
541
  $column_header{notes} =
542
    "<th class=listheading>" . $locale->text('Notes') . "</th>";
543
  $column_header{debit} =
544
    "<th class=listheading>" . $locale->text('Debit') . "</th>";
545
  $column_header{debit_accno} =
546
      "<th><a class=listheading href=$href&sort=accno>"
547
    . $locale->text('Debit Account')
548
    . "</a></th>";
549
  $column_header{credit} =
550
    "<th class=listheading>" . $locale->text('Credit') . "</th>";
551
  $column_header{credit_accno} =
552
      "<th><a class=listheading href=$href&sort=accno>"
553
    . $locale->text('Credit Account')
554
    . "</a></th>";
555
  $column_header{debit_tax} =
556
      "<th><a class=listheading href=$href&sort=accno>"
557
    . $locale->text('Debit Tax')
558
    . "</a></th>";
559
  $column_header{debit_tax_accno} =
560
      "<th><a class=listheading href=$href&sort=accno>"
561
    . $locale->text('Debit Tax Account')
562
    . "</a></th>";
563
  $column_header{credit_tax} =
564
      "<th><a class=listheading href=$href&sort=accno>"
565
    . $locale->text('Credit Tax')
566
    . "</a></th>";
567
  $column_header{credit_tax_accno} =
568
      "<th><a class=listheading href=$href&sort=accno>"
569
    . $locale->text('Credit Tax Account')
570
    . "</a></th>";
571
  $column_header{gifi_accno} =
572
      "<th><a class=listheading href=$href&sort=gifi_accno>"
573
    . $locale->text('GIFI')
574
    . "</a></th>";
575
  $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
576

  
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
  
577 461
  $form->{landscape} = 1;
578

  
462
  
579 463
  $form->header;
580 464

  
581 465
  print qq|
......
596 480
	<tr class=listheading>
597 481
|;
598 482

  
599
  map { print "$column_header{$_}\n" } @column_index;
483
map { print "$column_header{$_}\n" } @column_index;
600 484

  
601
  print "
485
print "
602 486
        </tr>
603 487
        </thead>
604 488
        </tfoot>
605 489
        <tbody>
606 490
";
607

  
491
  
608 492
  # add sort to callback
609 493
  $form->{callback} = "$callback&sort=$form->{sort}";
610 494
  $callback = $form->escape($form->{callback});
611

  
495
  
612 496
  # initial item for subtotals
613 497
  if (@{ $form->{GL} }) {
614
    $sameitem = $form->{GL}->[0]->{ $form->{sort} };
498
    $sameitem = $form->{GL}->[0]->{$form->{sort}};
615 499
  }
616

  
500
  
617 501
  if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
618 502

  
619 503
    map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
620
    $column_data{balance} =
621
        "<td align=right>"
622
      . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
623
      . "</td>";
624

  
625
    $i++;
626
    $i %= 2;
504
    $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
505
    
506
    $i++; $i %= 2;
627 507
    print qq|
628 508
        <tr class=listrow$i>
629 509
|;
630 510
    map { print "$column_data{$_}\n" } @column_index;
631

  
511
    
632 512
    print qq|
633 513
        </tr>
634 514
|;
635 515
  }
636

  
516
    
637 517
  foreach $ref (@{ $form->{GL} }) {
638 518

  
639 519
    # if item ne sort print subtotal
640 520
    if ($form->{l_subtotal} eq 'Y') {
641
      if ($sameitem ne $ref->{ $form->{sort} }) {
642
        &gl_subtotal;
521
      if ($sameitem ne $ref->{$form->{sort}}) {
522
	&gl_subtotal;
643 523
      }
644 524
    }
645
    foreach $key (sort keys(%{ $ref->{amount} })) {
525
    foreach $key (sort keys (%{$ref->{amount}})) {
646 526
      $form->{balance} += $ref->{amount}{$key};
647 527
    }
648

  
528
    
649 529
    $debit = "";
650
    foreach $key (sort keys(%{ $ref->{debit} })) {
530
    foreach $key (sort keys (%{$ref->{debit}})) {
651 531
      $subtotaldebit += $ref->{debit}{$key};
652
      $totaldebit    += $ref->{debit}{$key};
532
      $totaldebit += $ref->{debit}{$key};
653 533
      if ($key == 0) {
654
        $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
534
        $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
655 535
      } else {
656
        $debit .=
657
          "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
536
        $debit .= "<br>".$form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
658 537
      }
659 538
    }
660

  
539
    
661 540
    $credit = "";
662
    foreach $key (sort keys(%{ $ref->{credit} })) {
541
    foreach $key (sort keys (%{$ref->{credit}})) {
663 542
      $subtotalcredit += $ref->{credit}{$key};
664
      $totalcredit    += $ref->{credit}{$key};
543
      $totalcredit += $ref->{credit}{$key};
665 544
      if ($key == 0) {
666
        $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
545
        $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
667 546
      } else {
668
        $credit .= "<br>"
669
          . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
670
      }
547
        $credit .= "<br>".$form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
548
      }      
671 549
    }
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff