Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7d91a3cf

Von Rolf Fluehmann vor fast 7 Jahren hinzugefügt

  • ID 7d91a3cfe2ad0b6397a620268bb5939596982a5a
  • Vorgänger 4487bcbf
  • Nachfolger b0fc2ec2

Erfolgsrechnung kann nach Abteilung gefiltert werden

Unterschiede anzeigen:

SL/RP.pm
1902 1902
  my %categories = (I => "ERTRAG", E => "AUFWAND");
1903 1903
  my $fromdate = conv_dateq($form->{fromdate});
1904 1904
  my $todate = conv_dateq($form->{todate});
1905
  my $department_id = conv_i((split /--/, $form->{department})[1], 'NULL');
1905 1906

  
1906 1907
  $form->{total} = 0;
1907 1908

  
......
1909 1910
    my %category = (
1910 1911
      name => $categories{$category},
1911 1912
      total => 0,
1912
      accounts => get_accounts_ch($category),
1913
      accounts => get_accounts_ch($category)
1913 1914
    );
1914 1915
    foreach my $account (@{$category{accounts}}) {
1915
      $account->{total} += get_total_ch($account->{id}, $fromdate, $todate);
1916
      $account->{total} = get_total_ch($department_id, $account->{id}, $fromdate, $todate);
1916 1917
      $category{total} += $account->{total};
1917 1918
      $account->{total} = $form->format_amount($myconfig, $form->round_amount($account->{total}, 2), 2);
1918 1919
    }
......
1930 1931
  $main::lxdebug->enter_sub();
1931 1932

  
1932 1933
  my ($category) = @_;
1933
  my ($inclusion);
1934
  my $inclusion = '' ;
1934 1935

  
1935 1936
  if ($category eq 'I') {
1936 1937
    $inclusion = "AND pos_er = NULL OR pos_er = '1'";
......
1955 1956
sub get_total_ch {
1956 1957
  $main::lxdebug->enter_sub();
1957 1958

  
1958
  my ($chart_id, $fromdate, $todate) = @_;
1959
  my ($department_id, $chart_id, $fromdate, $todate) = @_;
1959 1960
  my $total = 0;
1960 1961
  my $query = qq|
1961 1962
    SELECT SUM(amount)
......
1964 1965
      AND transdate >= ?
1965 1966
      AND transdate <= ?
1966 1967
  |;
1967
  $total += _query($query, $chart_id, $fromdate, $todate)->[0]->{sum};
1968
  if ($department_id) {
1969
    $query .= qq| AND COALESCE(
1970
        (SELECT department_id FROM ar WHERE ar.id=trans_id),
1971
        (SELECT department_id FROM gl WHERE gl.id=trans_id),
1972
        (SELECT department_id FROM ap WHERE ap.id=trans_id)
1973
    ) = ? |;
1974
    $total += _query($query, $chart_id, $fromdate, $todate, $department_id)->[0]->{sum};
1975
  } else {
1976
    $total += _query($query, $chart_id, $fromdate, $todate)->[0]->{sum};
1977
  }
1968 1978

  
1969 1979
  $main::lxdebug->leave_sub();
1970 1980
  return $total;

Auch abrufbar als: Unified diff