Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fc1e3973

Von Rolf Fluehmann vor mehr als 8 Jahren hinzugefügt

  • ID fc1e397330501fecd1ea62511c0965f0a5ef27b6
  • Vorgänger 335fc788
  • Nachfolger 030c2086

Erfolgsrechnung

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
  #injection-filter
1877
  $form->{fromdate} =~ s/[^0-9\.]//g;
1878
  $form->{todate} =~ s/[^0-9\.]//g;
1879
  #input validation
1880
  $form->{fromdate} = "01.01.2000" if $form->{fromdate} !~ m/[0-9]*\.[0-9]*\.[0-9]*/;
1881
  $form->{todate} = $form->current_date(%{$myconfig}) if $form->{todate} !~ m/[0-9]*\.[0-9]*\.[0-9]*/;
1882

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

  
1887
  $form->{total} = 0;
1888

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

  
1906
  $main::lxdebug->leave_sub();
1907
  return {};
1908
}
1909

  
1910
sub get_accounts_ch {
1911
  $main::lxdebug->enter_sub();
1912

  
1913
  my ($category) = @_;
1914
  my ($inclusion);
1915

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

  
1924
  my $query = qq|
1925
    SELECT id, accno, description, category
1926
    FROM chart
1927
    WHERE category = '$category' $inclusion
1928
    ORDER BY accno
1929
  |;
1930
  my $accounts = _query($query);
1931

  
1932
  $main::lxdebug->leave_sub();
1933
  return $accounts;
1934
}
1935

  
1936
sub get_total_ch {
1937
  $main::lxdebug->enter_sub();
1938

  
1939
  my ($chart_id, $fromdate, $todate) = @_;
1940
  my $total = 0;
1941
  my $query = qq|
1942
    SELECT SUM(amount)
1943
    FROM acc_trans
1944
    WHERE chart_id = '$chart_id'
1945
      AND transdate >= $fromdate
1946
      AND transdate <= $todate
1947
  |;
1948
  $total += _query($query)->[0]->{sum};
1949

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

  
1954
sub _query {return selectall_hashref_query($::form, $::form->get_standard_dbh, @_);}
1955

  
1869 1956
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');
sql/Pg-upgrade2/chart_pos_er.sql
5 5
-- @may_fail: 1
6 6

  
7 7
ALTER TABLE chart ADD COLUMN pos_er INTEGER;
8
UPDATE chart SET pos_er = pos_eur;
sql/Switzerland-deutsch-MWST-2014-chart.sql
3 3
-- Korrigiert: November 2015
4 4
-- Grundlage: Revision OR Stand 1.1.2013, insbesondere Art. 957a Abs. 2
5 5

  
6
ALTER TABLE chart ADD COLUMN pos_er INTEGER;
7

  
8 6
DELETE FROM chart;
9 7

  
10
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_er, datevautomatik, valid_from) VALUES
8
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_eur, datevautomatik, valid_from) VALUES
11 9
('1',    'AKTIVEN','H','','','1',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
12 10
('10',   'UMLAUFSVERMÖGEN','H','','','10',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
13 11
('100',  'Flüssige Mittel','H','','','100',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
sql/Switzerland-deutsch-ohneMWST-2014-chart.sql
3 3
-- Korrigiert: November 2015
4 4
-- Grundlage: Revision OR Stand 1.1.2013, insbesondere Art. 957a Abs. 2
5 5

  
6
ALTER TABLE chart ADD COLUMN pos_er INTEGER;
7

  
8 6
DELETE FROM chart;
9 7

  
10
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_er, datevautomatik, valid_from) VALUES
8
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_eur, datevautomatik, valid_from) VALUES
11 9
('1',    'AKTIVEN','H','','','1',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
12 10
('10',   'UMLAUFSVERMÖGEN','H','','','10',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
13 11
('100',  'Flüssige Mittel','H','','','100',0,NULL,NULL,NULL,NULL,FALSE,'2011-01-01 00:00:00.000000'),
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" checked 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" 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 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