Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision acd5752a

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID acd5752aff6f10f3d19b33da176a07895efcb964
  • Vorgänger 3c2e635c
  • Nachfolger c1e220bf

GuV: Partielle Zahlungen berücksichtigen.

Siehe Bug 1190.

Unterschiede anzeigen:

SL/RP.pm
447 447
      $subwhere .= " AND (transdate    >= $fromdate)";
448 448
      $glwhere   = " AND (ac.transdate >= $fromdate)";
449 449
      $prwhere   = " AND (a.transdate  >= $fromdate)";
450
      $inwhere   = " AND (acc.transdate >= $fromdate)";
450 451
    } else {
451 452
      $where    .= " AND (ac.transdate >= $fromdate)";
452 453
    }
......
457 458
    $subwhere   .= " AND (transdate    <= $todate)";
458 459
    $where      .= " AND (ac.transdate <= $todate)";
459 460
    $prwhere    .= " AND (a.transdate  <= $todate)";
461
    $inwhere    .= " AND (acc.transdate <= $todate)";
460 462
  }
461 463

  
462 464
  if ($department_id) {
......
468 470
    $project = qq| AND (ac.project_id = | . conv_i($form->{project_id}) . qq|) |;
469 471
  }
470 472

  
473
#
474
# GUV patch by Ronny Rentner (Bug 1190)
475
#
476
# GUV IST-Versteuerung
477
#
478
# Alle tatsaechlichen _Zahlungseingaenge_
479
# im Zeitraum erfassen
480
# (Teilzahlungen werden prozentual auf verschiedene Steuern aufgeteilt)
481
#
482
#
483

  
471 484
  if ($form->{method} eq 'cash') {
472 485
    $query =
473 486
      qq|
487
       SELECT SUM( ac.amount *
488
                    (SELECT SUM(acc.amount) * -1
489
                     FROM acc_trans acc
490
                     INNER JOIN chart c ON (acc.chart_id = c.id AND c.link LIKE '%AR_paid%')
491
                     WHERE 1=1 $inwhere AND acc.trans_id = ac.trans_id)
492
                  / (SELECT amount FROM ar WHERE id = ac.trans_id)
493
                ) AS amount, c.pos_eur
494
       FROM acc_trans ac
495
       LEFT JOIN chart c ON (c.id  = ac.chart_id)
496
       LEFT JOIN ar      ON (ar.id = ac.trans_id)
497
       LEFT JOIN taxkeys tk ON (tk.id = (
498
                                  SELECT id FROM taxkeys
499
                                  WHERE chart_id = ac.chart_id
500
                                  AND startdate <= COALESCE(ar.deliverydate,ar.transdate)
501
                                  ORDER BY startdate DESC LIMIT 1
502
                                  )
503
                                )
504
      WHERE ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE 1=1 $subwhere)
505

  
506
      GROUP BY c.pos_eur
507

  
508
/*
474 509
       SELECT SUM(ac.amount * chart_category_to_sgn(c.category)) AS amount, c.$category
475 510
         FROM acc_trans ac
476 511
         JOIN chart c ON (c.id = ac.chart_id)
......
480 515
           AND ac.trans_id IN ( SELECT trans_id FROM acc_trans JOIN chart ON (chart_id = id) WHERE (link LIKE '%AR_paid%') $subwhere)
481 516
           $project
482 517
         GROUP BY c.$category
483

  
518
*/
484 519
         UNION
485 520

  
486 521
         SELECT SUM(ac.amount * chart_category_to_sgn(c.category)) AS amount, c.$category
......
588 623
  my $accno;
589 624
  my $ref;
590 625

  
591
  my $sth = prepare_execute_query($form, $dbh, $query);
592

  
593
  while ($ref = $sth->fetchrow_hashref("NAME_lc")) {
626
  foreach my $ref (selectall_hashref_query($form, $dbh, $query)) {
594 627
    if ($category eq "pos_bwa") {
595 628
      if ($last_period) {
596 629
        $form->{ $ref->{$category} }{kumm} += $ref->{amount};
......
601 634
      $form->{ $ref->{$category} } += $ref->{amount};
602 635
    }
603 636
  }
604
  $sth->finish;
605 637

  
606 638
  $main::lxdebug->leave_sub();
607 639
}
......
774 806
    $where .=
775 807
      qq| AND(ac.trans_id IN (SELECT id FROM ar WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM ap WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM gl WHERE transdate>= $fromdate AND transdate<= $todate)) AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) AND (NOT ac.cb_transaction OR ac.cb_transaction IS NULL) |;
776 808
    $saldowhere .= qq| AND(ac.trans_id IN (SELECT id FROM ar WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM ap WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM gl WHERE transdate>= $fromdate AND transdate<= $todate))  AND (NOT ac.cb_transaction OR ac.cb_transaction IS NULL) |;
777
      
809

  
778 810
    $sumwhere .= qq| AND(ac.trans_id IN (SELECT id FROM ar WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM ap WHERE datepaid>= $fromdate AND datepaid<= $todate UNION SELECT id FROM gl WHERE transdate>= $fromdate AND transdate<= $todate)) AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) AND (NOT ac.cb_transaction OR ac.cb_transaction IS NULL) |;
779 811
  } else {
780 812
    $where .= $tofrom . " AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) AND (NOT ac.cb_transaction OR ac.cb_transaction IS NULL)";

Auch abrufbar als: Unified diff