Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e3f82371

Von Rolf Fluehmann vor fast 9 Jahren hinzugefügt

  • ID e3f8237101c331c52098cf6f7db86e1db2a2b36a
  • Vorgänger 73a78da6
  • Nachfolger 422f2f17

Erfolgsrechnung

Unterschiede anzeigen:

SL/RP.pm
1871 1871
  }
1872 1872
  $main::lxdebug->leave_sub();
1873 1873
}
1874

  
1875
sub erfolgsrechnung {
1876
  $main::lxdebug->enter_sub();
1877

  
1878
  my ($self, $myconfig, $form) = @_;
1879
  $form->{company} = $::instance_conf->get_company;
1880
  $form->{address} = $::instance_conf->get_address;
1881

  
1882
  # wrong user inputs should be handled during users input
1883
  # e.g.  spaces, tabs, wrong format or wrong dates
1884
  $form->{fromdate} = "01.01.2000" if !$form->{fromdate};
1885
  $form->{todate} = $form->current_date(%{$myconfig}) if !$form->{todate};
1886

  
1887
  my %categories = (I => "ERTRAG", E => "AUFWAND");
1888
  my $fromdate = conv_dateq($form->{fromdate});
1889
  my $todate = conv_dateq($form->{todate});
1890

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

  
1909
  $main::lxdebug->leave_sub();
1910
  return {};
1911
}
1912

  
1913
sub get_accounts_ch {
1914
  $main::lxdebug->enter_sub();
1915

  
1916
  my ($category) = @_;
1917
  my ($inclusion);
1918

  
1919
  if ($category eq 'I') {
1920
    $inclusion = "AND pos_eur = NULL OR pos_eur > '0' AND pos_eur <= '5'";
1921
  } elsif ($category eq 'E') {
1922
    $inclusion = "AND pos_eur = NULL OR pos_eur >= '6' AND pos_eur < '100'";
1923
  } else {
1924
    $inclusion = "";
1925
  }
1926

  
1927
  my $query = qq|
1928
    SELECT id, accno, description, category
1929
    FROM chart
1930
    WHERE category = ? $inclusion
1931
    ORDER BY accno
1932
  |;
1933
  my $accounts = selectall_hashref_query($::form, $::form->get_standard_dbh, $query, $category);
1934

  
1935
  $main::lxdebug->leave_sub();
1936
  return $accounts;
1937
}
1938

  
1939
sub get_total_ch {
1940
  $main::lxdebug->enter_sub();
1941

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

  
1954
  $main::lxdebug->leave_sub();
1955
  return $total;
1956
}
1957

  
1874 1958
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
  'bwa'              => 'report',
112
  '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
  'erfolgsrechnung'    => 'report',
112
  'bwa'                => 'report',
113
  'balance_sheet'      => 'report',
113 114
};
114 115

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

  
143 145
  $::form->{title} = $title{$::form->{report}};
144 146
  $::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;
145 149

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

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

  
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)$/;
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)$/;
162 167

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

  
192 197
  $::form->header;
193 198
  print $::form->parse_html_template('rp/report', {
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,
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,
208 214
  });
209 215

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

  
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

  
398 423
sub generate_balance_sheet {
399 424
  $::lxdebug->enter_sub;
400 425
  $::auth->assert('report');
menus/user/00-erp.yaml
772 772
  params:
773 773
    action: report
774 774
    report: trial_balance
775
- parent: reports
776
  id: reports_erfolgsrechnung
777
  name: Erfolgsrechnung
778
  icon: income_statement
779
  order: 300
780
  access: report
781
  module: rp.pl
782
  params:
783
    action: report
784
    report: erfolgsrechnung
775 785
- parent: reports
776 786
  id: reports_income_statement
777 787
  name: Income Statement
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><input name=year size=11 title="[% 'YYYY' | $T8 %]" value="[% year %]" class="initial_focus"></td>
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>
13 15
  </tr>
14 16
  <tr>
15 17
    <td align=right> <b>[% 'Yearly' | $T8 %]</b> </td>
......
17 19
    <th align=left colspan=3>[% 'Monthly' | $T8 %]</th>
18 20
  </tr>
19 21
  <tr>
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>
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>
25 37
  </tr>
26 38
  <tr>
27 39
    <td align= right>&nbsp;</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>
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>
32 52
  </tr>
33 53
  <tr>
34 54
    <td> &nbsp;</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>
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>
39 67
  </tr>
40 68
  <tr>
41 69
    <td> &nbsp;</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>
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>
46 82
  </tr>
47 83
  <tr>
48 84
    <td colspan=5><hr size=3 noshade></td>
......
51 87
    <th align=left><input name=reporttype class=radio type=radio value="free">[% 'Free report period' | $T8 %]</th>
52 88
    <td align=left colspan=4>
53 89
      [% 'From' | $T8 %] [% L.date_tag('fromdate', fromdate) %]
54
      [% 'Bis' | $T8 %] [% L.date_tag('todate') %]
90
      [% 'Bis' | $T8 %] [% L.date_tag('todate', todate)  %]
55 91
    </td>
56 92
  </tr>
57 93
  <tr>
......
125 161
  </tr>
126 162
[%- END %]
127 163

  
164

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

  
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

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

  
325 371
</form>
372

  
373
<script type="text/javascript">
374
function format_date(yy, mm, dd) {
375
  var format = "[% dateformat %]";
376
  format = format.replace("yyyy", "yy");
377
  format = format.replace("yy", yy);
378
  format = format.replace("mm", mm);
379
  format = format.replace("dd", dd);
380
  return format;
381
}
382
function set_from_to(duetyp, year) {
383
  switch(duetyp) {
384
    case '1':
385
      document.getElementById('fromdate').value=format_date(year, '01', '01');
386
      document.getElementById('todate').value=format_date(year, '01', '31');
387
    break;
388
    case '2':
389
      document.getElementById('fromdate').value=format_date(year, '02', '01');
390
      if(year % 4) document.getElementById('todate').value=format_date(year, '02', '28');
391
      else document.getElementById('todate').value=format_date(year, '2', '29');
392
    break;
393
    case '3':
394
      document.getElementById('fromdate').value=format_date(year, '03', '01');
395
      document.getElementById('todate').value=format_date(year, '03', '31');
396
    break;
397
    case '4':
398
      document.getElementById('fromdate').value=format_date(year, '04', '01');
399
      document.getElementById('todate').value=format_date(year, '04', '30');
400
    break;
401
    case '5':
402
      document.getElementById('fromdate').value=format_date(year, '05', '01');
403
      document.getElementById('todate').value=format_date(year, '05', '31');
404
    break;
405
    case '6':
406
      document.getElementById('fromdate').value=format_date(year, '06', '01');
407
      document.getElementById('todate').value=format_date(year, '06', '30');
408
    break;
409
    case '7':
410
      document.getElementById('fromdate').value=format_date(year, '07', '01');
411
      document.getElementById('todate').value=format_date(year, '07', '31');
412
    break;
413
    case '8':
414
      document.getElementById('fromdate').value=format_date(year, '08', '01');
415
      document.getElementById('todate').value=format_date(year, '08', '31');
416
    break;
417
    case '9':
418
      document.getElementById('fromdate').value=format_date(year, '09', '01');
419
      document.getElementById('todate').value=format_date(year, '09', '30');
420
    break;
421
    case '10':
422
      document.getElementById('fromdate').value=format_date(year, '10', '01');
423
      document.getElementById('todate').value=format_date(year, '10', '31');
424
    break;
425
    case '11':
426
      document.getElementById('fromdate').value=format_date(year, '11', '01');
427
      document.getElementById('todate').value=format_date(year, '11', '30');
428
    break;
429
    case '12':
430
      document.getElementById('fromdate').value=format_date(year, '12', '01');
431
      document.getElementById('todate').value=format_date(year, '12', '31');
432
    break;
433
    case '13':
434
      document.getElementById('fromdate').value=format_date(year, '01', '01');
435
      document.getElementById('todate').value=format_date(year, '12', '31');
436
    break;
437
    case 'A':
438
      document.getElementById('fromdate').value=format_date(year, '01', '01');
439
      document.getElementById('todate').value=format_date(year, '03', '31');
440
    break;
441
    case 'B':
442
      document.getElementById('fromdate').value=format_date(year, '04', '01');
443
      document.getElementById('todate').value=format_date(year, '06', '30');
444
    break;
445
    case 'C':
446
      document.getElementById('fromdate').value=format_date(year, '07', '01');
447
      document.getElementById('todate').value=format_date(year, '09', '31');
448
    break;
449
    case 'D':
450
      document.getElementById('fromdate').value=format_date(year, '10', '01');
451
      document.getElementById('todate').value=format_date(year, '12', '31');
452
    break;
453
    default:
454
      document.getElementById('fromdate').value=format_date(year, '01', '01');
455
      document.getElementById('todate').value=format_date(year, '12', '31');
456
  }
457
  return true;
458
}
459
</script>
460

  

Auch abrufbar als: Unified diff