Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f1e5fd2d

Von Udo Spallek vor fast 19 Jahren hinzugefügt

  • ID f1e5fd2d8c139e903899a984cf4b116afb2efd47
  • Vorgänger 1ef9fe2f
  • Nachfolger 0320615c

Neuer Patch gegen den Unbalanced Ledger!
Betr. Bugzilla ID 124

Unterschiede anzeigen:

SL/GL.pm
298 298
    ($form->{ml}) = $sth->fetchrow_array;
299 299
    $sth->finish;
300 300

  
301
    #if ($form->{datefrom}) {
301
    if ($form->{datefrom}) {
302 302
      $query = qq|SELECT SUM(ac.amount)
303 303
		  FROM acc_trans ac, chart c
304 304
		  WHERE ac.chart_id = c.id
305
                  AND c.accno = '$form->{accno}'|;
306
      $query .= qq|AND ac.transdate > date '$form->{datefrom}'
307
 		  | if ($form->{datefrom});;
308
      $query .= qq|AND ac.transdate < date '$form->{dateto}'
309
                  | if ($form->{dateto});
310

  
305
		  AND c.accno = '$form->{accno}'
306
		  AND ac.transdate < date '$form->{datefrom}'
307
		  |;
311 308
      $sth = $dbh->prepare($query);
312 309
      $sth->execute || $form->dberror($query);
313 310

  
314 311
      ($form->{balance}) = $sth->fetchrow_array;
315 312
      $sth->finish;
316
    #}
313
    }
317 314
  }
318 315

  
319 316
  if ($form->{gifi_accno}) {
......
348 345
  my $query =
349 346
    qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
350 347
                 g.description, ac.transdate, ac.source, ac.trans_id,
351
		 ac.amount*100 AS amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
348
		 ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
352 349
                 FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON
353 350
                 (t.chart_id=c.id)
354 351
                 WHERE $glwhere
......
357 354
	UNION
358 355
	         SELECT a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, t.taxkey AS sorttax,
359 356
		 ct.name, ac.transdate, ac.source, ac.trans_id,
360
		 ac.amount*100 AS amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
357
		 ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
361 358
		 FROM ar a, acc_trans ac, customer ct, chart c LEFT JOIN tax t ON
362 359
                 (t.chart_id=c.id)
363 360
		 WHERE $arwhere
......
367 364
	UNION
368 365
	         SELECT a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, t.taxkey AS sorttax,
369 366
		 ct.name, ac.transdate, ac.source, ac.trans_id,
370
		 ac.amount*100 AS amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
367
		 ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
371 368
		 FROM ap a, acc_trans ac, vendor ct, chart c LEFT JOIN tax t ON
372 369
                 (t.chart_id=c.id)
373 370
		 WHERE $apwhere
......
404 401
      }
405 402
    }
406 403
    $balance = $ref->{amount};
407
    $ref->{amount} = $ref->{amount} * 1.0;
408 404
    $i       = 0;
409 405
    $j       = 0;
410 406
    $k       = 0;
411 407
    $l       = 0;
412 408
    if ($ref->{amount} < 0) {
413 409
      if ($ref->{chart_id} > 0) {
414
        $ref->{debit_tax}{$i}       = ($ref->{amount} / 100.0) * -1;
410
        $ref->{debit_tax}{$i}       = $ref->{amount} * -1;
415 411
        $ref->{debit_tax_accno}{$i} = $ref->{accno};
416 412
      } else {
417
        $ref->{debit}{$k}        = ($ref->{amount} / 100.0) * -1;
413
        $ref->{debit}{$k}        = $ref->{amount} * -1;
418 414
        $ref->{debit_accno}{$k}  = $ref->{accno};
419 415
        $ref->{debit_taxkey}{$k} = $ref->{taxkey};
420 416
      }
421 417
    } else {
422 418
      if ($ref->{chart_id} > 0) {
423
        $ref->{credit_tax}{$j}       = $ref->{amount} / 100.0;
419
        $ref->{credit_tax}{$j}       = $ref->{amount};
424 420
        $ref->{credit_tax_accno}{$j} = $ref->{accno};
425 421
      } else {
426
        $ref->{credit}{$l}        = $ref->{amount} / 100.0;
422
        $ref->{credit}{$l}        = $ref->{amount};
427 423
        $ref->{credit_accno}{$l}  = $ref->{accno};
428 424
        $ref->{credit_taxkey}{$l} = $ref->{taxkey};
429 425
      }
430 426
    }
431
#    if ($form->{accno} eq ''){ # flo & udo: if general report,
432
                            # then check balance
433
                            
434
#    while ($balance  != 0) {
435
#      my $ref2 = $sth->fetchrow_hashref(NAME_lc)
436
#        || $form->error(sprintf("Unbalanced ledger! trans-id: %i", $ref->{trans_id}));
437
#
438
#      $balance =
439
#        (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
440
#      $balance += $ref2->{amount};
441
      
442
      #print(STDERR $balance, " BAlance\n");
443
      #print(STDERR $ref2->{amount}, " Ref2->amount\n");
444
#      if ($ref2->{amount} < 0) {
445
#        if ($ref2->{chart_id} > 0) {
446
#          if ($ref->{debit_tax_accno}{$i} ne "") {
447
#            $i++;
448
#          }
449
#          $ref->{debit_tax}{$i}       = ($ref2->{amount} / 100.0) * -1;
450
#          $ref->{debit_tax_accno}{$i} = $ref2->{accno};
451
#        } else {
452
#          if ($ref->{debit_accno}{$k} ne "") {
453
#            $k++;
454
#          }
455
#          $ref->{debit}{$k}        = ($ref2->{amount} / 100.0) * -1;
456
#          $ref->{debit_accno}{$k}  = $ref2->{accno};
457
#          $ref->{debit_taxkey}{$k} = $ref2->{taxkey};
458
#        }
459
#      } else {
460
#        if ($ref2->{chart_id} > 0) {
461
#          if ($ref->{credit_tax_accno}{$j} ne "") {
462
#            $j++;
463
#          }
464
#          $ref->{credit_tax}{$j}       = $ref2->{amount} / 100.0;
465
#          $ref->{credit_tax_accno}{$j} = $ref2->{accno};
466
#        } else {
467
#          if ($ref->{credit_accno}{$l} ne "") {
468
#            $l++;
469
#          }
470
#          $ref->{credit}{$l}        = $ref2->{amount} / 100.0;
471
#          $ref->{credit_accno}{$l}  = $ref2->{accno};
472
#          $ref->{credit_taxkey}{$l} = $ref2->{taxkey};
473
#        }
474
#      }
475
#    }
476
#    } else {
477
#    1;
478
#    }
427
    if ($form->{accno} eq ''){ # flo & udo: if general report,
428
                               # then check balance
429
      while (abs($balance) >= 0.015) {
430
        my $ref2 = $sth->fetchrow_hashref(NAME_lc)
431
          || $form->error("Unbalanced ledger!");
432

  
433
        $balance =
434
          (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
435
        print(STDERR $balance, " BAlance\n");
436
        print(STDERR $ref2->{amount}, " Ref2->amount\n");
437
        if ($ref2->{amount} < 0) {
438
          if ($ref2->{chart_id} > 0) {
439
            if ($ref->{debit_tax_accno}{$i} ne "") {
440
              $i++;
441
            }
442
            $ref->{debit_tax}{$i}       = $ref2->{amount} * -1;
443
            $ref->{debit_tax_accno}{$i} = $ref2->{accno};
444
          } else {
445
            if ($ref->{debit_accno}{$k} ne "") {
446
              $k++;
447
            }
448
            $ref->{debit}{$k}        = $ref2->{amount} * -1;
449
            $ref->{debit_accno}{$k}  = $ref2->{accno};
450
            $ref->{debit_taxkey}{$k} = $ref2->{taxkey};
451
          }
452
        } else {
453
          if ($ref2->{chart_id} > 0) {
454
            if ($ref->{credit_tax_accno}{$j} ne "") {
455
              $j++;
456
            }
457
            $ref->{credit_tax}{$j}       = $ref2->{amount};
458
            $ref->{credit_tax_accno}{$j} = $ref2->{accno};
459
          } else {
460
            if ($ref->{credit_accno}{$l} ne "") {
461
              $l++;
462
            }
463
            $ref->{credit}{$l}        = $ref2->{amount};
464
            $ref->{credit_accno}{$l}  = $ref2->{accno};
465
            $ref->{credit_taxkey}{$l} = $ref2->{taxkey};
466
          }
467
        }
468
      }
469
    } else {
470
      # if account-report, then calculate the Balance?!
471
      # ToDo: Calculate the Balance
472
      1;
473
    }
474
       
479 475
    #    print(STDERR Dumper($ref));
480 476
    push @{ $form->{GL} }, $ref;
481 477
    $balance = 0;

Auch abrufbar als: Unified diff