Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 335fc788

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID 335fc788611b85c4879e701fba2892ec1ed2c8dd
  • Vorgänger 12727b13
  • Nachfolger fc1e3973

Revert "Erfolgsrechnung"

This reverts commit e3f8237101c331c52098cf6f7db86e1db2a2b36a.

Unterschiede anzeigen:

SL/RP.pm
1866 1866
  }
1867 1867
  $main::lxdebug->leave_sub();
1868 1868
}
1869

  
1870
sub erfolgsrechnung {
1871
  $main::lxdebug->enter_sub();
1872

  
1873
  my ($self, $myconfig, $form) = @_;
1874
  $form->{company} = $::instance_conf->get_company;
1875
  $form->{address} = $::instance_conf->get_address;
1876

  
1877
  # wrong user inputs should be handled during users input
1878
  # e.g.  spaces, tabs, wrong format or wrong dates
1879
  $form->{fromdate} = "01.01.2000" if !$form->{fromdate};
1880
  $form->{todate} = $form->current_date(%{$myconfig}) if !$form->{todate};
1881

  
1882
  my %categories = (I => "ERTRAG", E => "AUFWAND");
1883
  my $fromdate = conv_dateq($form->{fromdate});
1884
  my $todate = conv_dateq($form->{todate});
1885

  
1886
  $form->{total} = 0;
1887
  foreach my $category (keys %categories) {
1888
    my %category = (
1889
      name => $categories{$category},
1890
      total => 0,
1891
      accounts => get_accounts_ch($category),
1892
    );
1893
    foreach my $account (@{$category{accounts}}) {
1894
      $account->{total} += ($account->{category} eq $category ? 1 : -1) * get_total_ch($account->{id}, $fromdate, $todate);
1895
      $category{total} += $account->{total};
1896
      $account->{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $account->{total}), 2);
1897
    }
1898
    $form->{total} += $category{total};
1899
    $category{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $category{total}), 2);
1900
    push(@{$form->{categories}}, \%category);
1901
  }
1902
  $form->{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $form->{total}), 2);
1903

  
1904
  $main::lxdebug->leave_sub();
1905
  return {};
1906
}
1907

  
1908
sub get_accounts_ch {
1909
  $main::lxdebug->enter_sub();
1910

  
1911
  my ($category) = @_;
1912
  my ($inclusion);
1913

  
1914
  if ($category eq 'I') {
1915
    $inclusion = "AND pos_er = NULL OR pos_er > '0' AND pos_er <= '5'";
1916
  } elsif ($category eq 'E') {
1917
    $inclusion = "AND pos_er = NULL OR pos_er >= '6' AND pos_er < '100'";
1918
  } else {
1919
    $inclusion = "";
1920
  }
1921

  
1922
  my $query = qq|
1923
    SELECT id, accno, description, category
1924
    FROM chart
1925
    WHERE category = ? $inclusion
1926
    ORDER BY accno
1927
  |;
1928
  my $accounts = selectall_hashref_query($::form, $::form->get_standard_dbh, $query, $category);
1929

  
1930
  $main::lxdebug->leave_sub();
1931
  return $accounts;
1932
}
1933

  
1934
sub get_total_ch {
1935
  $main::lxdebug->enter_sub();
1936

  
1937
  my ($chart_id, $fromdate, $todate) = @_;
1938
  my $total = 0;
1939
  my $query = qq|
1940
    SELECT SUM(amount)
1941
    FROM acc_trans
1942
    WHERE chart_id = ?
1943
      AND transdate >= ?
1944
      AND transdate <= ?
1945
  |;
1946
  my $data = selectfirst_hashref_query($::form, $::form->get_standard_dbh, $query, $chart_id, $fromdate, $todate);
1947
  $total += $data->{sum};
1948

  
1949
  $main::lxdebug->leave_sub();
1950
  return $total;
1951
}
1952

  
1953 1869
1;
bin/mozilla/rp.pl
101 101
# $form->parse_html_template('rp/html_report_susa')
102 102

  
103 103
my $rp_access_map = {
104
  'projects'           => 'report',
105
  'ar_aging'           => 'general_ledger',
106
  'ap_aging'           => 'general_ledger',
107
  'receipts'           => 'cash',
108
  'payments'           => 'cash',
109
  'trial_balance'      => 'report',
110
  'income_statement'   => 'report',
111
  'erfolgsrechnung'    => 'report',
112
  'bwa'                => 'report',
113
  'balance_sheet'      => 'report',
104
  'projects'         => 'report',
105
  'ar_aging'         => 'general_ledger',
106
  'ap_aging'         => 'general_ledger',
107
  'receipts'         => 'cash',
108
  'payments'         => 'cash',
109
  'trial_balance'    => 'report',
110
  'income_statement' => 'report',
111
  'bwa'              => 'report',
112
  'balance_sheet'    => 'report',
114 113
};
115 114

  
116 115
sub check_rp_access {
......
130 129
  my %title = (
131 130
    balance_sheet        => $::locale->text('Balance Sheet'),
132 131
    income_statement     => $::locale->text('Income Statement'),
133
    erfolgsrechnung      => $::locale->text('Erfolgsrechnung'),
134 132
    trial_balance        => $::locale->text('Trial Balance'),
135 133
    ar_aging             => $::locale->text('Search AR Aging'),
136 134
    ap_aging             => $::locale->text('Search AP Aging'),
......
144 142

  
145 143
  $::form->{title} = $title{$::form->{report}};
146 144
  $::request->{layout}->add_javascripts('autocomplete_customer.js');
147
  $::form->{fromdate} = DateTime->today->truncate(to => 'year')->to_kivitendo;
148
  $::form->{todate} = DateTime->today->truncate(to => 'year')->add(years => 1)->add(days => -1)->to_kivitendo;
149 145

  
150 146
  # get departments
151 147
  $::form->all_departments(\%::myconfig);
......
156 152

  
157 153
  $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 });
158 154

  
159
  my $is_projects            = $::form->{report} eq "projects";
160
  my $is_income_statement    = $::form->{report} eq "income_statement";
161
  my $is_erfolgsrechnung     = $::form->{report} eq "erfolgsrechnung";
162
  my $is_bwa                 = $::form->{report} eq "bwa";
163
  my $is_balance_sheet       = $::form->{report} eq "balance_sheet";
164
  my $is_trial_balance       = $::form->{report} eq "trial_balance";
165
  my $is_aging               = $::form->{report} =~ /^a[rp]_aging$/;
166
  my $is_payments            = $::form->{report} =~ /(receipts|payments)$/;
155
  my $is_projects         = $::form->{report} eq "projects";
156
  my $is_income_statement = $::form->{report} eq "income_statement";
157
  my $is_bwa              = $::form->{report} eq "bwa";
158
  my $is_balance_sheet    = $::form->{report} eq "balance_sheet";
159
  my $is_trial_balance    = $::form->{report} eq "trial_balance";
160
  my $is_aging            = $::form->{report} =~ /^a[rp]_aging$/;
161
  my $is_payments         = $::form->{report} =~ /(receipts|payments)$/;
167 162

  
168 163
  my ($label, $nextsub, $vc);
169 164
  if ($is_aging) {
......
196 191

  
197 192
  $::form->header;
198 193
  print $::form->parse_html_template('rp/report', {
199
    paymentaccounts        => $paymentaccounts,
200
    selection              => $selection,
201
    is_aging               => $is_aging,
202
    vc                     => $vc,
203
    label                  => $label,
204
    year                   => DateTime->today->year,
205
    today                  => DateTime->today,
206
    nextsub                => $nextsub,
207
    is_payments            => $is_payments,
208
    is_trial_balance       => $is_trial_balance,
209
    is_balance_sheet       => $is_balance_sheet,
210
    is_bwa                 => $is_bwa,
211
    is_income_statement    => $is_income_statement,
212
    is_erfolgsrechnung     => $is_erfolgsrechnung,
213
    is_projects            => $is_projects,
194
    paymentaccounts     => $paymentaccounts,
195
    selection           => $selection,
196
    is_aging            => $is_aging,
197
    vc                  => $vc,
198
    label               => $label,
199
    year                => DateTime->today->year,
200
    today               => DateTime->today,
201
    nextsub             => $nextsub,
202
    is_payments         => $is_payments,
203
    is_trial_balance    => $is_trial_balance,
204
    is_balance_sheet    => $is_balance_sheet,
205
    is_bwa              => $is_bwa,
206
    is_income_statement => $is_income_statement,
207
    is_projects         => $is_projects,
214 208
  });
215 209

  
216 210
  $::lxdebug->leave_sub;
......
401 395
  $main::lxdebug->leave_sub();
402 396
}
403 397

  
404
sub generate_erfolgsrechnung {
405
  $::lxdebug->enter_sub;
406
  $::auth->assert('report');
407

  
408
  $::form->{decimalplaces} = $::form->{decimalplaces} * 1 || 2;
409
  $::form->{padding}       = "&emsp;";
410
  $::form->{bold}          = "<b>";
411
  $::form->{endbold}       = "</b>";
412
  $::form->{br}            = "<br>";
413

  
414
  my $data = RP->erfolgsrechnung(\%::myconfig, $::form);
415

  
416
  $::form->header();
417
  print $::form->parse_html_template('rp/erfolgsrechnung', $data);
418

  
419
  $::lxdebug->leave_sub;
420
}
421

  
422

  
423 398
sub generate_balance_sheet {
424 399
  $::lxdebug->enter_sub;
425 400
  $::auth->assert('report');
templates/webpages/rp/erfolgsrechnung.html
1
[%- USE T8 %]
2
[%- USE HTML %]
3
[%- USE LxERP %]
4

  
5
<h2 align="center">
6
  <br>[% company %]
7
  <br>[% address %]
8
  <p>[% 'ERFOLGSRECHNUNG' %]
9
  <br>[% fromdate %] bis [% todate %]
10
</h2>
11
<table border="0">
12
  <tr>
13
    <th align="left" width="400" colspan="2"><br></th>
14
  </tr>
15
  [%- FOREACH category = categories %]
16
    <tr valign="top">
17
      <th align="left" colspan="4">[% category.name %]<b><hr align="left" width="250" size="5" noshade></th>
18
    </tr>
19
    [%- FOREACH row = category.accounts %]
20
      <tr>
21
        <td align="left">[% row.accno %]</td>
22
        <td align="left">[% row.description %]</td>
23
        <td align="right">[% row.total %]</td>
24
      </tr>
25
    [%- END %]
26
    <tr>
27
      <td colspan="2"> </td>
28
      <td><hr noshade size="1"></td>
29
      <td><hr noshade size="1"></td>
30
    </tr>
31
    <tr valign="top">
32
      <th align="left" colspan="2">TOTAL</th>
33
      <td align="right">[% category.total %]<hr noshade size="2"></td>
34
    </tr>
35
  [%- END %]
36
  <tr valign="top">
37
    <th align="left" colspan="2">GEWINN/VERLUST</th>
38
    <td align="right">[% total %]<br><hr noshade size="2"></td>
39
  </tr>
40
</table>
templates/webpages/rp/report.html
9 9
  </tr>
10 10
  <tr>
11 11
    <th colspan=1>[% 'Year' | $T8 %]</th>
12
    <td>
13
      <input name=year size=11 title="[% 'YYYY' | $T8 %]" value="[% year %]" class="initial_focus" oninput='set_from_to(duetyp.value, this.value)'>
14
    </td>
12
    <td><input name=year size=11 title="[% 'YYYY' | $T8 %]" value="[% year %]" class="initial_focus"></td>
15 13
  </tr>
16 14
  <tr>
17 15
    <td align=right> <b>[% 'Yearly' | $T8 %]</b> </td>
......
19 17
    <th align=left colspan=3>[% 'Monthly' | $T8 %]</th>
20 18
  </tr>
21 19
  <tr>
22
    <td align=right>&nbsp;
23
      <input name=duetyp class=radio type=radio value="13" onchange='set_from_to(this.value, year.value)'>
24
    </td>
25
    <td><input name=duetyp class=radio type=radio value="A" onchange='set_from_to(this.value, year.value)'>
26
      &nbsp;1. [% 'Quarter' | $T8 %]
27
    </td>
28
    <td><input name=duetyp class=radio type=radio value="1" checked onchange='set_from_to(this.value, year.value)'>
29
      &nbsp;[% 'January' | $T8 %]
30
    </td>
31
    <td><input name=duetyp class=radio type=radio value="5" onchange='set_from_to(this.value, year.value)'>
32
      &nbsp;[% 'May' | $T8 %]
33
    </td>
34
    <td><input name=duetyp class=radio type=radio value="9" onchange='set_from_to(this.value, year.value)'>
35
      &nbsp;[% 'September' | $T8 %]
36
    </td>
20
    <td align=right>&nbsp; <input name=duetyp class=radio type=radio value="13"></td>
21
    <td><input name=duetyp class=radio type=radio value="A">&nbsp;1. [% 'Quarter' | $T8 %]</td>
22
    <td><input name=duetyp class=radio type=radio value="1" checked>&nbsp;[% 'January' | $T8 %]</td>
23
    <td><input name=duetyp class=radio type=radio value="5">&nbsp;[% 'May' | $T8 %]</td>
24
    <td><input name=duetyp class=radio type=radio value="9">&nbsp;[% 'September' | $T8 %]</td>
37 25
  </tr>
38 26
  <tr>
39 27
    <td align= right>&nbsp;</td>
40
    <td><input name=duetyp class=radio type=radio value="B" onchange='set_from_to(this.value, year.value)'>
41
      &nbsp;2. [% 'Quarter' | $T8 %]
42
    </td>
43
    <td><input name=duetyp class=radio type=radio value="2" onchange='set_from_to(this.value, year.value)'>
44
      &nbsp;[% 'February' | $T8 %]
45
    </td>
46
    <td><input name=duetyp class=radio type=radio value="6" onchange='set_from_to(this.value, year.value)'>
47
      &nbsp;[% 'June' | $T8 %]
48
    </td>
49
    <td><input name=duetyp class=radio type=radio value="10" onchange='set_from_to(this.value, year.value)'>
50
      &nbsp;[% 'October' | $T8 %]
51
    </td>
28
    <td><input name=duetyp class=radio type=radio value="B">&nbsp;2. [% 'Quarter' | $T8 %]</td>
29
    <td><input name=duetyp class=radio type=radio value="2">&nbsp;[% 'February' | $T8 %]</td>
30
    <td><input name=duetyp class=radio type=radio value="6">&nbsp;[% 'June' | $T8 %]</td>
31
    <td><input name=duetyp class=radio type=radio value="10">&nbsp;[% 'October' | $T8 %]</td>
52 32
  </tr>
53 33
  <tr>
54 34
    <td> &nbsp;</td>
55
    <td><input name=duetyp class=radio type=radio value="C" onchange='set_from_to(this.value, year.value)'>
56
      &nbsp;3. [% 'Quarter' | $T8 %]
57
    </td>
58
    <td><input name=duetyp class=radio type=radio value="3" onchange='set_from_to(this.value, year.value)'>
59
      &nbsp;[% 'March' | $T8 %]
60
    </td>
61
    <td><input name=duetyp class=radio type=radio value="7" onchange='set_from_to(this.value, year.value)'>
62
      &nbsp;[% 'July' | $T8 %]
63
    </td>
64
    <td><input name=duetyp class=radio type=radio value="11" onchange='set_from_to(this.value, year.value)'>
65
      &nbsp;[% 'November' | $T8 %]
66
    </td>
35
    <td><input name=duetyp class=radio type=radio value="C">&nbsp;3. [% 'Quarter' | $T8 %]</td>
36
    <td><input name=duetyp class=radio type=radio value="3">&nbsp;[% 'March' | $T8 %]</td>
37
    <td><input name=duetyp class=radio type=radio value="7">&nbsp;[% 'July' | $T8 %]</td>
38
    <td><input name=duetyp class=radio type=radio value="11">&nbsp;[% 'November' | $T8 %]</td>
67 39
  </tr>
68 40
  <tr>
69 41
    <td> &nbsp;</td>
70
    <td><input name=duetyp class=radio type=radio value="D" onchange='set_from_to(this.value, year.value)'>
71
      &nbsp;4. [% 'Quarter' | $T8 %]
72
    </td>
73
    <td><input name=duetyp class=radio type=radio value="4" onchange='set_from_to(this.value, year.value)'>
74
      &nbsp;[% 'April' | $T8 %]
75
    </td>
76
    <td><input name=duetyp class=radio type=radio value="8" onchange='set_from_to(this.value, year.value)'>
77
      &nbsp;[% 'August' | $T8 %]
78
    </td>
79
    <td><input name=duetyp class=radio type=radio value="12" onchange='set_from_to(this.value, year.value)'>
80
      &nbsp;[% 'December' | $T8 %]
81
    </td>
42
    <td><input name=duetyp class=radio type=radio value="D">&nbsp;4. [% 'Quarter' | $T8 %]</td>
43
    <td><input name=duetyp class=radio type=radio value="4">&nbsp;[% 'April' | $T8 %]</td>
44
    <td><input name=duetyp class=radio type=radio value="8">&nbsp;[% 'August' | $T8 %]</td>
45
    <td><input name=duetyp class=radio type=radio value="12">&nbsp;[% 'December' | $T8 %]</td>
82 46
  </tr>
83 47
  <tr>
84 48
    <td colspan=5><hr size=3 noshade></td>
......
87 51
    <th align=left><input name=reporttype class=radio type=radio value="free">[% 'Free report period' | $T8 %]</th>
88 52
    <td align=left colspan=4>
89 53
      [% 'From' | $T8 %] [% L.date_tag('fromdate', fromdate) %]
90
      [% 'Bis' | $T8 %] [% L.date_tag('todate', todate)  %]
54
      [% 'Bis' | $T8 %] [% L.date_tag('todate') %]
91 55
    </td>
92 56
  </tr>
93 57
  <tr>
......
161 125
  </tr>
162 126
[%- END %]
163 127

  
164

  
165 128
[%- IF is_bwa %]
166 129
[%- PROCESS projectnumber %]
167 130
  <input type=hidden name=nextsub value=generate_bwa>
......
175 138
  </tr>
176 139
[%- END %]
177 140

  
178

  
179
[%- IF is_erfolgsrechnung %]
180
  <input type=hidden name=nextsub value=generate_erfolgsrechnung>
181
</table>
182
<table>
183
[%- PROCESS customized_report %]
184
[%- END %]
185

  
186

  
187 141
[%- IF is_balance_sheet %]
188 142
  <input type=hidden name=nextsub value=generate_balance_sheet>
189 143
  <tr>
......
369 323
<input type=submit class=submit name=action value="[% 'Continue' | $T8 %]">
370 324

  
371 325
</form>
372

  
373
<script type="text/javascript">
374
function set_from_to(duetyp, year) {
375
  var date = {
376
    1:  [ 1,  1, 1,  31 ],
377
    2:  [ 2,  1, 2,  new Date(year, 1, 29).getMonth() == 1 ? 29 : 28 ],
378
    3:  [ 3,  1, 3,  31 ],
379
    4:  [ 4,  1, 4,  30 ],
380
    5:  [ 5,  1, 5,  31 ],
381
    6:  [ 6,  1, 6,  30 ],
382
    7:  [ 7,  1, 7,  31 ],
383
    8:  [ 8,  1, 8,  31 ],
384
    9:  [ 9,  1, 9,  30 ],
385
    10: [ 10, 1, 10, 31 ],
386
    11: [ 11, 1, 11, 30 ],
387
    12: [ 12, 1, 12, 31 ],
388
    13: [  1, 1, 12, 31 ],
389
    'A': [ 1,  1, 3,  31 ],
390
    'B': [ 4,  1, 6,  30 ],
391
    'C': [ 7,  1, 9,  30 ],
392
    'D': [ 10, 1, 12, 31 ]
393
  }[duetyp];
394

  
395
  $('#fromdate').val(kivi.format_date(new Date(year, date[0]-1, date[1])));
396
  $('#todate').val(kivi.format_date(new Date(year, date[2]-1, date[3])));
397

  
398
  return true;
399
}
400
</script>
401

  

Auch abrufbar als: Unified diff