Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f2f0fb50

Von G. Richardson vor mehr als 4 Jahren hinzugefügt

  • ID f2f0fb505e860155c2a548bf03c3ca47da312560
  • Vorgänger da2f5aa8
  • Nachfolger a565eee3

Jahresabschluß - YearEndTransactions neu implementiert

Der alte Jahresabschluß hatte eine Reihe von Schwächen, z.B. wurde nicht
zwischen Bestands- und Erfolgskonten unterschieden, und es wurde auch
kein Gewinn- oder Verlustvortrag gemacht. Der Anwender mußte selber
entscheiden, welche Konten abgeschlossen werden sollten.

  • Saldenvortragskonto, sowie Gewinn- und Verlustvortragskonto müssen in
    der Mandantenkonfiguration unter "Standardkonten" konfiguriert werden
  • Es wird nicht mehr für jedes Konto eine Dialogbuchung erstellt,
    sondern es werden alle Soll- und Habensalden zusammengefasst, und
    diese in Summe gegen das Saldenvortragskonto gebucht
  • Der Jahresabschluß lässt sich für einen bestimmten Zeitraum mehrmals
    ausführen, falls später Buchungen für den Zeitraum hinzukommen.

Unterschiede anzeigen:

SL/Controller/YearEndTransactions.pm
4 4

  
5 5
use parent qw(SL::Controller::Base);
6 6

  
7
use utf8; # Umlauts in hardcoded German default texts
7 8
use DateTime;
8 9
use SL::Locale::String qw(t8);
9
use SL::ReportGenerator;
10 10
use SL::Helper::Flash;
11 11
use SL::DBUtils;
12
use Data::Dumper;
13
use List::Util qw(sum);
14
use SL::ClientJS;
12 15

  
13 16
use SL::DB::Chart;
14 17
use SL::DB::GLTransaction;
15 18
use SL::DB::AccTransaction;
16
use SL::DB::Helper::AccountingPeriod qw(get_balance_starting_date);
17

  
18
use SL::Presenter::Tag qw(checkbox_tag);
19
use SL::DB::Employee;
20
use SL::DB::Helper::AccountingPeriod qw(get_balance_starting_date get_balance_startdate_method_options);
19 21

  
20 22
use Rose::Object::MakeMethods::Generic (
21
  'scalar --get_set_init' => [ qw(charts charts9000 cbob_chart cb_date cb_startdate ob_date cb_reference ob_reference cb_description ob_description) ],
23
  'scalar --get_set_init' => [ qw(cb_date cb_startdate ob_date) ],
22 24
);
23 25

  
24 26
__PACKAGE__->run_before('check_auth');
25 27

  
26
sub action_filter {
28
sub action_form {
27 29
  my ($self) = @_;
28
  $self->ob_date(DateTime->today->truncate(to => 'year'))                  if !$self->ob_date;
29
  $self->cb_date(DateTime->today->truncate(to => 'year')->add(days => -1)) if !$self->cb_date;
30
  $self->ob_reference(t8('OB Transaction'))   if !$self->ob_reference;
31
  $self->cb_reference(t8('CB Transaction'))   if !$self->cb_reference;
32
  $self->ob_description(t8('OB Transaction')) if !$self->ob_description;
33
  $self->cb_description(t8('CB Transaction')) if !$self->cb_description;
34

  
35
  $self->setup_filter_action_bar;
36
  $self->render('gl/yearend_filter',
37
                title               => t8('CB/OB Transactions'),
38
                make_title_of_chart => sub { $_[0]->accno.' '.$_[0]->description }
39
               );
40 30

  
41
}
31
  $self->cb_startdate($::locale->parse_date_to_object($self->get_balance_starting_date($self->cb_date)));
32

  
33
  my $defaults         = SL::DB::Default->get;
34
  my $carry_over_chart = SL::DB::Manager::Chart->find_by( id => $defaults->carry_over_account_chart_id     );
35
  my $profit_chart     = SL::DB::Manager::Chart->find_by( id => $defaults->profit_carried_forward_chart_id );
36
  my $loss_chart       = SL::DB::Manager::Chart->find_by( id => $defaults->loss_carried_forward_chart_id   );
37

  
38
  $self->render('yearend/form',
39
                title                            => t8('Year-end closing'),
40
                carry_over_chart                 => $carry_over_chart,
41
                profit_chart                     => $profit_chart,
42
                loss_chart                       => $loss_chart,
43
                balance_startdate_method_options => get_balance_startdate_method_options(),
44
               );
45
};
42 46

  
43
sub action_list {
47
sub action_year_end_bookings {
44 48
  my ($self) = @_;
45
  $main::lxdebug->enter_sub();
46 49

  
47
  my $report     = SL::ReportGenerator->new(\%::myconfig, $::form);
50
  $self->_parse_form;
51

  
48 52

  
49
  $self->prepare_report($report);
53
  eval {
54
    _year_end_bookings( start_date => $self->cb_startdate,
55
                        cb_date    => $self->cb_date,
56
                      );
57
    1;
58
  } or do {
59
    $self->js->flash('error', t8('Error while applying year-end bookings!') . ' ' . $@);
60
    return $self->js->render;
61
  };
50 62

  
51
  $report->set_options(
52
    output_format        => 'HTML',
53
    raw_top_info_text    => $::form->parse_html_template('gl/yearend_top',    { SELF => $self }),
54
    raw_bottom_info_text => $::form->parse_html_template('gl/yearend_bottom', { SELF => $self }),
55
    allow_pdf_export     => 0,
56
    allow_csv_export     => 0,
57
    title                => $::locale->text('CB/OB Transactions'),
58
  );
63
  my ($report_data, $profit_loss_sum) = _report(
64
                                                cb_date    => $self->cb_date,
65
                                                start_date => $self->cb_startdate,
66
                                               );
59 67

  
60
  $self->setup_list_action_bar;
61
  $report->generate_with_headers();
62
  $main::lxdebug->leave_sub();
68
  my $html = $self->render('yearend/_charts', { layout  => 0 , process => 1, output => 0 },
69
                 charts          => $report_data,
70
                 profit_loss_sum => $profit_loss_sum,
71
               );
72
  return $self->js->flash('info', t8('Year-end bookings were successfully completed!'))
73
               ->html('#charts', $html)
74
               ->render;
63 75
}
64 76

  
65
sub action_generate {
77
sub action_get_start_date {
66 78
  my ($self) = @_;
67 79

  
68
  if ($self->cb_date > $self->ob_date) {
69
    flash ('error', $::locale->text('CB date #1 is higher than OB date #2. Please select again.', $self->cb_date, $self->ob_date));
70
  } else {
71
    my $cnt = $self->make_booking();
72
    flash('info', $::locale->text('#1 CB transactions and #1 OB transactions generated.',$cnt)) if $cnt > 0;
80
  my $cb_date = $self->cb_date; # parse from form via init
81
  unless ( $self->cb_date ) {
82
    return $self->hide('#apply_year_end_bookings_button')
83
                ->flash('error', t8('Year-end date missing'))
84
                ->render;
73 85
  }
74
  $self->action_list;
86

  
87
  $self->cb_startdate($::locale->parse_date_to_object($self->get_balance_starting_date($self->cb_date, $::form->{'balance_startdate_method'})));
88

  
89
  # $main::lxdebug->message(0, "found start date: ", $self->cb_startdate->to_kivitendo);
90

  
91
  return $self->js->val('#cb_startdate', $self->cb_startdate->to_kivitendo)
92
              ->show('#apply_year_end_bookings_button')
93
              ->show('.startdate')
94
              ->render;
75 95
}
76 96

  
77
sub check_auth {
78
  $::auth->assert('general_ledger');
97
sub action_update_charts {
98
  my ($self) = @_;
99

  
100
  $self->_parse_form;
101

  
102
  my ($report_data, $profit_loss_sum) = _report(
103
                                                cb_date   => $self->cb_date,
104
                                                start_date => $self->cb_startdate,
105
                                               );
106

  
107
  $self->render('yearend/_charts', { layout  => 0 , process => 1 },
108
                 charts          => $report_data,
109
                 profit_loss_sum => $profit_loss_sum,
110
               );
79 111
}
80 112

  
81 113
#
82 114
# helpers
83 115
#
84 116

  
85
sub make_booking {
117
sub _parse_form {
86 118
  my ($self) = @_;
87
  $main::lxdebug->enter_sub();
88
  my @ids = map { $::form->{"multi_id_$_"} } grep { $::form->{"multi_id_$_"} } (1..$::form->{rowcount});
89
  my $cnt = 0;
90
  $main::lxdebug->message(LXDebug->DEBUG2(),"generate for ".$::form->{cbob_chart}." # ".scalar(@ids)." charts");
91
  if (scalar(@ids) && $::form->{cbob_chart}) {
92
    my $carryoverchart = SL::DB::Manager::Chart->get_first(  query => [ id => $::form->{cbob_chart} ] );
93
    my $charts = SL::DB::Manager::Chart->get_all(  query => [ id => \@ids ] );
94
    foreach my $chart (@{ $charts }) {
95
      $main::lxdebug->message(LXDebug->DEBUG2(),"chart_id=".$chart->id." accno=".$chart->accno);
96
      my $balance = $self->get_balance($chart);
97
      if ( $balance != 0 ) {
98
        # SB
99
        $self->gl_booking($balance,$self->cb_date,$::form->{cb_reference},$::form->{cb_description},$chart,$carryoverchart,0,1);
100
        # EB
101
        $self->gl_booking($balance,$self->ob_date,$::form->{ob_reference},$::form->{ob_description},$carryoverchart,$chart,1,0);
102
        $cnt++;
103
      }
104
    }
105
  }
106
  $main::lxdebug->leave_sub();
107
  return $cnt;
119

  
120
  # parse dates
121
  $self->cb_startdate($::locale->parse_date_to_object($self->get_balance_starting_date($self->cb_date)));
122

  
123
  die "cb_date must come after start_date" unless $self->cb_date > $self->cb_startdate;
124

  
108 125
}
109 126

  
127
sub _year_end_bookings {
128
  my (%params) = @_;
110 129

  
111
sub prepare_report {
112
  my ($self,$report) = @_;
113
  $main::lxdebug->enter_sub();
114
  my $idx = 1;
130
  my $start_date = delete $params{start_date};
131
  my $cb_date    = delete $params{cb_date};
115 132

  
116
  my %column_defs = (
117
    'ids'         => { raw_header_data => checkbox_tag("", id => "check_all",
118
                                                                          checkall => "[data-checkall=1]"), 'align' => 'center' },
119
    'chart'       => { text => $::locale->text('Account'), },
120
    'description' => { text => $::locale->text('Description'), },
121
    'saldo'       => { text => $::locale->text('Saldo'),  'align' => 'right'},
122
    'sum_cb'      => { text => $::locale->text('Sum CB Transactions'), 'align' => 'right'},  ##close == Schluss
123
    'sum_ob'      => { text => $::locale->text('Sum OB Transactions'), 'align' => 'right'},  ##open  == Eingang
124
  );
125
  my @columns      = qw(ids chart description saldo sum_cb sum_ob);
126
  map { $column_defs{$_}->{visible} = 1 } @columns;
133
  my $defaults         = SL::DB::Default->get;
134
  my $carry_over_chart = SL::DB::Manager::Chart->find_by( id => $defaults->carry_over_account_chart_id     ) // die t8('No carry-over chart configured!');
135
  my $profit_chart     = SL::DB::Manager::Chart->find_by( id => $defaults->profit_carried_forward_chart_id ) // die t8('No profit carried forward chart configured!');
136
  my $loss_chart       = SL::DB::Manager::Chart->find_by( id => $defaults->loss_carried_forward_chart_id   ) // die t8('No profit and loss carried forward chart configured!');
127 137

  
128
  my $ob_next_date = $self->ob_date->clone();
129
  $ob_next_date->add(years => 1)->add(days => -1);
138
  my ($report_data, $profit_loss_sum) = _report(
139
                                                start_date => $start_date,
140
                                                cb_date    => $cb_date,
141
                                               );
130 142

  
131
  $self->cb_startdate($::locale->parse_date_to_object($self->get_balance_starting_date($self->cb_date)));
143
  my @asset_accounts       = grep { $_->{account_type} eq 'asset_account' }       @{ $report_data };
144
  my @profit_loss_accounts = grep { $_->{account_type} eq 'profit_loss_account' } @{ $report_data };
132 145

  
133
  my @custom_headers = ();
134
  # Zeile 1:
135
  push @custom_headers, [
136
      { 'text' => '   ', 'colspan' => 3 },
137
      { 'text' => $::locale->text("Timerange")."<br />".$self->cb_startdate->to_kivitendo." - ".$self->cb_date->to_kivitendo, 'colspan' => 2, 'align' => 'center'},
138
      { 'text' => $::locale->text("Timerange")."<br />".$self->ob_date->to_kivitendo." - ".$ob_next_date->to_kivitendo, 'align' => 'center'},
139
    ];
140

  
141
  # Zeile 2:
142
  my @line_2 = ();
143
  map { push @line_2 , $column_defs{$_} } grep { $column_defs{$_}->{visible} } @columns;
144
  push @custom_headers, [ @line_2 ];
145

  
146
  $report->set_custom_headers(@custom_headers);
147
  $report->set_columns(%column_defs);
148
  $report->set_column_order(@columns);
149

  
150
  my $chart9actual = SL::DB::Manager::Chart->get_first( query => [ id => $self->cbob_chart ] );
151
  $self->{cbob_chartaccno} = $chart9actual->accno.' '.$chart9actual->description;
152

  
153
  foreach my $chart (@{ $self->charts }) {
154
    my $balance = $self->get_balance($chart);
155
    if ( $balance != 0 ) {
156
      my $chart_id = $chart->id;
157
      my $row = { map { $_ => { 'data' => '' } } @columns };
158
      $row->{ids}  = {
159
        'raw_data' => checkbox_tag("multi_id_${idx}", value => $chart_id, "data-checkall" => 1),
160
        'valign'   => 'center',
161
        'align'    => 'center',
162
      };
163
      $row->{chart}->{data}       = $chart->accno;
164
      $row->{description}->{data} = $chart->description;
165
      if ( $balance > 0 ) {
166
        $row->{saldo}->{data} = $::form->format_amount(\%::myconfig, $balance, 2)." H";
167
      } elsif ( $balance < 0 )  {
168
        $row->{saldo}->{data} = $::form->format_amount(\%::myconfig,-$balance, 2)." S";
169
      } else {
170
        $row->{saldo}->{data} = $::form->format_amount(\%::myconfig,0, 2)."  ";
171
      }
172
      my $sum_cb = 0;
173
      foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id  => $chart->id, cb_transaction => 't',
174
                                                                               transdate => { ge => $self->cb_startdate},
175
                                                                               transdate => { le => $self->cb_date }
176
                                                                             ]) }) {
177
        $sum_cb += $acc->amount;
178
      }
179
      my $sum_ob = 0;
180
      foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id  => $chart->id, ob_transaction => 't',
181
                                                                               transdate => { ge => $self->ob_date},
182
                                                                               transdate => { le => $ob_next_date }
183
                                                                             ]) }) {
184
        $sum_ob += $acc->amount;
185
      }
186
      if ( $sum_cb > 0 ) {
187
        $row->{sum_cb}->{data} = $::form->format_amount(\%::myconfig, $sum_cb, 2)." H";
188
      } elsif ( $sum_cb < 0 )  {
189
        $row->{sum_cb}->{data} = $::form->format_amount(\%::myconfig,-$sum_cb, 2)." S";
190
      } else {
191
        $row->{sum_cb}->{data} = $::form->format_amount(\%::myconfig,0, 2)."  ";
192
      }
193
      if ( $sum_ob > 0 ) {
194
        $row->{sum_ob}->{data} = $::form->format_amount(\%::myconfig, $sum_ob, 2)." H";
195
      } elsif ( $sum_ob < 0 )  {
196
        $row->{sum_ob}->{data} = $::form->format_amount(\%::myconfig,-$sum_ob, 2)." S";
197
      } else {
198
        $row->{sum_ob}->{data} = $::form->format_amount(\%::myconfig,0, 2)."  ";
199
      }
200
      $report->add_data($row);
201
    }
202
    $idx++;
203
  }
146
  my $ob_date = $cb_date->clone->add(days => 1);
204 147

  
205
  $self->{row_count} = $idx;
206
  $main::lxdebug->leave_sub();
207
}
148
  my ($credit_sum, $debit_sum) = (0,0);
208 149

  
209
sub get_balance {
210
  $main::lxdebug->enter_sub();
211
  my ($self,$chart) = @_;
150
  my $employee_id = SL::DB::Manager::Employee->current->id;
212 151

  
213
  #$main::lxdebug->message(LXDebug->DEBUG2(),"get_balance from=".$self->cb_startdate->to_kivitendo." to=".$self->cb_date->to_kivitendo);
214
  my $balance = $chart->get_balance(fromdate => $self->cb_startdate, todate => $self->cb_date);
215
  $main::lxdebug->leave_sub();
216
  return 0 if !defined $balance || $balance == 0;
217
  return $balance;
218
}
152
	# rather than having one gl transaction for each asset account, we group all
153
  # the debit sums and credit sums for cb and ob bookings, so we will have 4 gl
154
  # transactions:
219 155

  
220
sub gl_booking {
221
  my ($self, $amount, $transdate, $reference, $description, $konto, $gegenkonto, $ob, $cb) = @_;
222
  $::form->get_employee();
223
  my $employee_id = $::form->{employee_id};
224
  $main::lxdebug->message(LXDebug->DEBUG2(),"employee_id=".$employee_id." ob=".$ob." cb=".$cb);
225
  my $gl_entry = SL::DB::GLTransaction->new(
226
    employee_id    => $employee_id,
227
    transdate      => $transdate,
228
    reference      => $reference,
229
    description    => $description,
230
    ob_transaction => $ob,
231
    cb_transaction => $cb,
232
  );
233
  #$gl_entry->save;
234
  my $kto_trans1 = SL::DB::AccTransaction->new(
235
    trans_id       => $gl_entry->id,
236
    transdate      => $transdate,
237
    ob_transaction => $ob,
238
    cb_transaction => $cb,
239
    chart_id       => $gegenkonto->id,
240
    chart_link     => $konto->link,
241
    tax_id         => 0,
242
    taxkey         => 0,
243
    amount         => $amount,
244
  );
245
  #$kto_trans1->save;
246
  my $kto_trans2 = SL::DB::AccTransaction->new(
247
    trans_id       => $gl_entry->id,
248
    transdate      => $transdate,
249
    ob_transaction => $ob,
250
    cb_transaction => $cb,
251
    chart_id       => $konto->id,
252
    chart_link     => $konto->link,
253
    tax_id         => 0,
254
    taxkey         => 0,
255
    amount         => -$amount,
256
  );
257
  #$kto_trans2->save;
258
  $gl_entry->add_transactions($kto_trans1);
259
  $gl_entry->add_transactions($kto_trans2);
260
  $gl_entry->save;
261
}
156
  # * cb for credit
157
  # * cb for debit
158
  # * ob for credit
159
  # * ob for debit
262 160

  
263
sub init_cbob_chart     { $::form->{cbob_chart}                                    }
264
sub init_ob_date        { $::locale->parse_date_to_object($::form->{ob_date})      }
265
sub init_ob_reference   { $::form->{ob_reference}                                  }
266
sub init_ob_description { $::form->{ob_description}                                }
267
sub init_cb_startdate   { $::locale->parse_date_to_object($::form->{cb_startdate}) }
268
sub init_cb_date        { $::locale->parse_date_to_object($::form->{cb_date})      }
269
sub init_cb_reference   { $::form->{cb_reference}                                  }
270
sub init_cb_description { $::form->{cb_description}                                }
161
  my $db = SL::DB->client;
162
  $db->with_transaction(sub {
271 163

  
272
sub init_charts9000 {
273
  SL::DB::Manager::Chart->get_all(  query => [ accno => { like => '9%'}] );
274
}
164
    ######### asset accounts ########
165
    # need cb and ob transactions
275 166

  
276
sub init_charts {
277
  # wie geht 'not like' in rose ?
278
  SL::DB::Manager::Chart->get_all(  query => [ \ "accno not like '9%'"], sort_by => 'accno ASC' );
279
}
167
    my $debit_balance  = 0;
168
    my $credit_balance = 0;
280 169

  
281
sub setup_filter_action_bar {
282
  my ($self) = @_;
170
    my $asset_cb_debit_entry = SL::DB::GLTransaction->new(
171
      employee_id    => $employee_id,
172
      transdate      => $cb_date,
173
      reference      => 'SB ' . $cb_date->year,
174
      description    => 'Automatische SB-Buchungen Bestandskonten Soll für ' . $cb_date->year,
175
      ob_transaction => 0,
176
      cb_transaction => 1,
177
    );
178
    my $asset_ob_debit_entry = SL::DB::GLTransaction->new(
179
      employee_id    => $employee_id,
180
      transdate      => $ob_date,
181
      reference      => 'EB ' . $ob_date->year,
182
      description    => 'Automatische EB-Buchungen Bestandskonten Haben für ' . $ob_date->year,
183
      ob_transaction => 1,
184
      cb_transaction => 0,
185
    );
186
    my $asset_cb_credit_entry = SL::DB::GLTransaction->new(
187
      employee_id    => $employee_id,
188
      transdate      => $cb_date,
189
      reference      => 'SB ' . $cb_date->year,
190
      description    => 'Automatische SB-Buchungen Bestandskonten Haben für ' . $cb_date->year,
191
      ob_transaction => 0,
192
      cb_transaction => 1,
193
    );
194
    my $asset_ob_credit_entry = SL::DB::GLTransaction->new(
195
      employee_id    => $employee_id,
196
      transdate      => $ob_date,
197
      reference      => 'EB ' . $ob_date->year,
198
      description    => 'Automatische EB-Buchungen Bestandskonten Soll für ' . $ob_date->year,
199
      ob_transaction => 1,
200
      cb_transaction => 0,
201
    );
202
    $asset_cb_debit_entry->transactions([]);
203
    $asset_ob_debit_entry->transactions([]);
204
    $asset_cb_credit_entry->transactions([]);
205
    $asset_ob_credit_entry->transactions([]);
206

  
207
    foreach my $asset_account ( @asset_accounts ) {
208
      next if $asset_account->{amount_with_cb} == 0;
209

  
210
      # create cb and ob acc_trans entry here, but decide which gl entry to add it to later
211
      my $asset_cb_acc = SL::DB::AccTransaction->new(
212
        transdate      => $cb_date,
213
        ob_transaction => 0,
214
        cb_transaction => 1,
215
        chart_id       => $asset_account->{chart_id},
216
        chart_link     => $asset_account->{chart_link},
217
        tax_id         => 0,
218
        taxkey         => 0,
219
        amount         => - $asset_account->{amount_with_cb},
220
      );
221
      my $asset_ob_acc = SL::DB::AccTransaction->new(
222
        transdate      => $ob_date,
223
        ob_transaction => 1,
224
        cb_transaction => 0,
225
        chart_id       => $asset_account->{chart_id},
226
        chart_link     => $asset_account->{chart_link},
227
        tax_id         => 0,
228
        taxkey         => 0,
229
        amount         => $asset_account->{amount_with_cb},
230
      );
231

  
232
      if ( $asset_account->{amount_with_cb} < 0 ) {
233
        $debit_balance += $asset_account->{amount_with_cb};
234
        # $main::lxdebug->message(0, sprintf("adding accno %s with balance %s to debit", $asset_account->{accno}, $asset_account->{amount_with_cb}));
235

  
236
        $asset_cb_debit_entry->add_transactions($asset_cb_acc);
237
        $asset_ob_debit_entry->add_transactions($asset_ob_acc);
238
      } else {
239
        # $main::lxdebug->message(0, sprintf("adding accno %s with balance %s to credit", $asset_account->{accno}, $asset_account->{amount_with_cb}));
240
        $credit_balance += $asset_account->{amount_with_cb};
241
        $asset_cb_credit_entry->add_transactions($asset_cb_acc);
242
        $asset_ob_credit_entry->add_transactions($asset_ob_acc);
243
      };
244
    };
245

  
246
    my $debit_cb_acc = SL::DB::AccTransaction->new(
247
      transdate      => $cb_date,
248
      ob_transaction => 0,
249
      cb_transaction => 1,
250
      chart_id       => $carry_over_chart->id,
251
      chart_link     => $carry_over_chart->link, # maybe leave chart_link empty?
252
      tax_id         => 0,
253
      taxkey         => 0,
254
      amount         => $debit_balance,
255
    );
256
    my $debit_ob_acc = SL::DB::AccTransaction->new(
257
      transdate      => $ob_date,
258
      ob_transaction => 1,
259
      cb_transaction => 0,
260
      chart_id       => $carry_over_chart->id,
261
      chart_link     => $carry_over_chart->link,
262
      tax_id         => 0,
263
      taxkey         => 0,
264
      amount         => - $debit_balance,
265
    );
266
    my $credit_cb_acc = SL::DB::AccTransaction->new(
267
      transdate      => $cb_date,
268
      ob_transaction => 0,
269
      cb_transaction => 1,
270
      chart_id       => $carry_over_chart->id,
271
      chart_link     => $carry_over_chart->link, # maybe leave chart_link empty?
272
      tax_id         => 0,
273
      taxkey         => 0,
274
      amount         => $credit_balance,
275
    );
276
    my $credit_ob_acc = SL::DB::AccTransaction->new(
277
      transdate      => $ob_date,
278
      ob_transaction => 1,
279
      cb_transaction => 0,
280
      chart_id       => $carry_over_chart->id,
281
      chart_link     => $carry_over_chart->link,
282
      tax_id         => 0,
283
      taxkey         => 0,
284
      amount         => - $credit_balance,
285
    );
286
    $asset_cb_debit_entry->add_transactions($debit_cb_acc);
287
    $asset_ob_debit_entry->add_transactions($debit_ob_acc);
288
    $asset_cb_credit_entry->add_transactions($credit_cb_acc);
289
    $asset_ob_credit_entry->add_transactions($credit_ob_acc);
290

  
291
    $asset_cb_debit_entry->save if scalar @{ $asset_cb_debit_entry->transactions } > 1;
292
    $asset_ob_debit_entry->save if scalar @{ $asset_ob_debit_entry->transactions } > 1;
293
    $asset_cb_credit_entry->save if scalar @{ $asset_cb_credit_entry->transactions } > 1;
294
    $asset_ob_credit_entry->save if scalar @{ $asset_ob_credit_entry->transactions } > 1;
295

  
296
    #######  profit-loss accounts #######
297
    # these only have a closing balance, the balance is transferred to the profit-loss account
298

  
299
    # need to know if profit or loss first!
300
    # use amount_with_cb, so it can be run several times. So sum may be 0 the second time.
301
    my $profit_loss_sum = sum map { $_->{amount_with_cb} }
302
                              grep { $_->{account_type} eq 'profit_loss_account' }
303
                              @{$report_data};
304
    my $pl_chart;
305
    if ( $profit_loss_sum > 0 ) {
306
      $pl_chart = $profit_chart;
307
    } else {
308
      $pl_chart = $loss_chart;
309
    };
310

  
311
    my $pl_debit_balance  = 0;
312
    my $pl_credit_balance = 0;
313
    # soll = debit, haben = credit
314
    my $pl_cb_debit_entry = SL::DB::GLTransaction->new(
315
      employee_id    => $employee_id,
316
      transdate      => $cb_date,
317
      reference      => 'SB ' . $cb_date->year,
318
      description    => 'Automatische SB-Buchungen Erfolgskonten Soll für ' . $cb_date->year,
319
      ob_transaction => 0,
320
      cb_transaction => 1,
321
    );
322
    my $pl_cb_credit_entry = SL::DB::GLTransaction->new(
323
      employee_id    => $employee_id,
324
      transdate      => $cb_date,
325
      reference      => 'SB ' . $cb_date->year,
326
      description    => 'Automatische SB-Buchungen Erfolgskonten Haben für ' . $cb_date->year,
327
      ob_transaction => 0,
328
      cb_transaction => 1,
329
    );
330
    $pl_cb_debit_entry->transactions([]);
331
    $pl_cb_credit_entry->transactions([]);
332

  
333
    foreach my $profit_loss_account ( @profit_loss_accounts ) {
334
      # $main::lxdebug->message(0, sprintf("found chart %s with balance %s", $profit_loss_account->{accno}, $profit_loss_account->{amount_with_cb}));
335

  
336
      next if $profit_loss_account->{amount_with_cb} == 0;
337

  
338
      my $debit_cb_acc = SL::DB::AccTransaction->new(
339
        transdate      => $cb_date,
340
        ob_transaction => 0,
341
        cb_transaction => 1,
342
        chart_id       => $profit_loss_account->{chart_id},
343
        chart_link     => $profit_loss_account->{chart_link},
344
        tax_id         => 0,
345
        taxkey         => 0,
346
        amount         => - $profit_loss_account->{amount_with_cb},
347
      );
348
      my $credit_cb_acc = SL::DB::AccTransaction->new(
349
        transdate      => $cb_date,
350
        ob_transaction => 0,
351
        cb_transaction => 1,
352
        chart_id       => $profit_loss_account->{chart_id},
353
        chart_link     => $profit_loss_account->{chart_link},
354
        tax_id         => 0,
355
        taxkey         => 0,
356
        amount         => $profit_loss_account->{amount_with_cb},
357
      );
358
      if ( { $profit_loss_account->{amount_with_cb} < 0 } ) {
359
        $pl_debit_balance += $profit_loss_account->{amount_with_cb};
360
         $pl_cb_debit_entry->add_transactions($debit_cb_acc);
361
      } else {
362
        $pl_credit_balance += $profit_loss_account->{amount_with_cb};
363
         $pl_cb_credit_entry->add_transactions($credit_cb_acc);
364
      };
365
    };
366

  
367
    my $debit_cb_acc = SL::DB::AccTransaction->new(
368
      transdate      => $cb_date,
369
      ob_transaction => 0,
370
      cb_transaction => 1,
371
      chart_id       => $pl_chart->id,
372
      chart_link     => $pl_chart->link,
373
      tax_id         => 0,
374
      taxkey         => 0,
375
      amount         => $pl_debit_balance,
376
    );
377
    my $credit_cb_acc = SL::DB::AccTransaction->new(
378
      transdate      => $cb_date,
379
      ob_transaction => 0,
380
      cb_transaction => 1,
381
      chart_id       => $pl_chart->id,
382
      chart_link     => $pl_chart->link,
383
      tax_id         => 0,
384
      taxkey         => 0,
385
      amount         => - $pl_credit_balance,
386
    );
387
    $pl_cb_debit_entry->add_transactions($debit_cb_acc);
388
    $pl_cb_credit_entry->add_transactions($credit_cb_acc);
389

  
390
    $pl_cb_debit_entry->save  if scalar @{ $pl_cb_debit_entry->transactions }  > 1;
391
    $pl_cb_credit_entry->save if scalar @{ $pl_cb_credit_entry->transactions } > 1;
392

  
393
    ######### profit-loss transfer #########
394
    # and finally transfer the new balance of the profit-loss account via the carry-over account
395
    # we want to use profit_loss_sum with cb!
396

  
397
    my $carry_over_cb_entry = SL::DB::GLTransaction->new(
398
      employee_id    => $employee_id,
399
      transdate      => $cb_date,
400
      reference      => 'SB ' . $cb_date->year,
401
      description    => sprintf('Automatische SB-Buchung für %s %s',
402
                                $profit_loss_sum >= 0 ? 'Gewinnvortrag' : 'Verlustvortrag',
403
                                $cb_date->year,
404
                               ),
405
      ob_transaction => 0,
406
      cb_transaction => 1,
407
    );
408
    my $carry_over_ob_entry = SL::DB::GLTransaction->new(
409
      employee_id    => $employee_id,
410
      transdate      => $ob_date,
411
      reference      => 'EB ' . $ob_date->year,
412
      description    => sprintf('Automatische EB-Buchung für %s %s',
413
                                $profit_loss_sum >= 0 ? 'Gewinnvortrag' : 'Verlustvortrag',
414
                                $ob_date->year,
415
                               ),
416
      ob_transaction => 1,
417
      cb_transaction => 0,
418
    );
419
    $carry_over_cb_entry->transactions([]);
420
    $carry_over_ob_entry->transactions([]);
421

  
422
    my $carry_over_cb_acc_co = SL::DB::AccTransaction->new(
423
      transdate      => $cb_date,
424
      ob_transaction => 0,
425
      cb_transaction => 1,
426
      chart_id       => $carry_over_chart->id,
427
      chart_link     => $carry_over_chart->link,
428
      tax_id         => 0,
429
      taxkey         => 0,
430
      amount         => $profit_loss_sum,
431
    );
432
    my $carry_over_cb_acc_pl = SL::DB::AccTransaction->new(
433
      transdate      => $cb_date,
434
      ob_transaction => 0,
435
      cb_transaction => 1,
436
      chart_id       => $pl_chart->id,
437
      chart_link     => $pl_chart->link,
438
      tax_id         => 0,
439
      taxkey         => 0,
440
      amount         => - $profit_loss_sum,
441
    );
283 442

  
284
  for my $bar ($::request->layout->get('actionbar')) {
285
    $bar->add(
286
      action => [
287
        t8('Continue'),
288
        submit    => [ '#filter_form', { action => 'YearEndTransactions/list' } ],
289
        accesskey => 'enter',
290
      ],
443
    $carry_over_cb_entry->add_transactions($carry_over_cb_acc_co);
444
    $carry_over_cb_entry->add_transactions($carry_over_cb_acc_pl);
445
    $carry_over_cb_entry->save if $profit_loss_sum != 0;
446

  
447
    my $carry_over_ob_acc_co = SL::DB::AccTransaction->new(
448
      transdate      => $ob_date,
449
      ob_transaction => 1,
450
      cb_transaction => 0,
451
      chart_id       => $pl_chart->id,
452
      chart_link     => $pl_chart->link,
453
      tax_id         => 0,
454
      taxkey         => 0,
455
      amount         => $profit_loss_sum,
291 456
    );
292
  }
457
    my $carry_over_ob_acc_pl = SL::DB::AccTransaction->new(
458
      transdate      => $ob_date,
459
      ob_transaction => 1,
460
      cb_transaction => 0,
461
      chart_id       => $carry_over_chart->id,
462
      chart_link     => $carry_over_chart->link,
463
      tax_id         => 0,
464
      taxkey         => 0,
465
      amount         => - $profit_loss_sum,
466
    );
467

  
468
    $carry_over_ob_entry->add_transactions($carry_over_ob_acc_co);
469
    $carry_over_ob_entry->add_transactions($carry_over_ob_acc_pl);
470
    $carry_over_ob_entry->save if $profit_loss_sum != 0;
471

  
472
    my $consistency_query = <<SQL;
473
select sum(amount)
474
  from acc_trans
475
 where     (ob_transaction is true or cb_transaction is true)
476
       and (transdate = ? or transdate = ?)
477
SQL
478
     my ($sum) = my ($empty) = selectrow_query($::form, $db->dbh, $consistency_query,
479
                                               $cb_date,
480
                                               $ob_date
481
                                              );
482
     die "acc_trans transactions don't add up to zero" unless $sum == 0;
483

  
484
    1;
485
  }) or die $db->error;
293 486
}
294 487

  
295
sub setup_list_action_bar {
296
  my ($self) = @_;
488
sub _report {
489
  my (%params) = @_;
490

  
491
  my $start_date = delete $params{start_date};
492
  my $cb_date    = delete $params{cb_date};
493

  
494
  my $defaults = SL::DB::Default->get;
495
  die "no carry over account defined"
496
    unless defined $defaults->carry_over_account_chart_id
497
           and $defaults->carry_over_account_chart_id > 0;
498

  
499
  my $salden_query = <<SQL;
500
select c.id as chart_id,
501
       c.accno,
502
       c.description,
503
       c.link as chart_link,
504
       c.category,
505
       sum(a.amount) filter (where cb_transaction is false and ob_transaction is false) as amount,
506
       sum(a.amount) filter (where ob_transaction is true                             ) as ob_amount,
507
       sum(a.amount) filter (where cb_transaction is false                            ) as amount_without_cb,
508
       sum(a.amount) filter (where cb_transaction is true                             ) as cb_amount,
509
       sum(a.amount)                                                                    as amount_with_cb,
510
       case when c.category = ANY( '{I,E}'     ) then 'profit_loss_account'
511
            when c.category = ANY( '{A,C,L,Q}' ) then 'asset_account'
512
                                                 else null
513
            end                                                                         as account_type
514
  from acc_trans a
515
       inner join chart c on (c.id = a.chart_id)
516
 where     a.transdate >= ?
517
       and a.transdate <= ?
518
       and a.chart_id != ?
519
 group by c.id, c.accno, c.category
520
 order by account_type, c.accno
521
SQL
522

  
523
  my $dbh = SL::DB->client->dbh;
524
  my $report = selectall_hashref_query($::form, $dbh, $salden_query,
525
                                       $start_date,
526
                                       $cb_date,
527
                                       $defaults->carry_over_account_chart_id,
528
                                      );
529
  # profit_loss_sum is the actual profit/loss for the year, without cb, use "amount_without_cb")
530
  my $profit_loss_sum = sum map { $_->{amount_without_cb} }
531
                            grep { $_->{account_type} eq 'profit_loss_account' }
532
                            @{$report};
533

  
534
  return ($report, $profit_loss_sum);
535
}
297 536

  
298
  for my $bar ($::request->layout->get('actionbar')) {
299
    $bar->add(
300
      action => [
301
        t8('Post'),
302
        submit    => [ '#form', { action => 'YearEndTransactions/generate' } ],
303
        tooltip   => t8('generate cb/ob transactions for selected charts'),
304
        confirm   => t8('Are you sure to generate cb/ob transactions?'),
305
        accesskey => 'enter',
306
      ],
307
      action => [
308
        t8('Back'),
309
        call => [ 'kivi.history_back' ],
310
      ],
311
    );
312
  }
537
#
538
# auth
539
#
540

  
541
sub check_auth {
542
  $::auth->assert('general_ledger');
313 543
}
314 544

  
545

  
546
#
547
# inits
548
#
549

  
550
sub init_ob_date        { $::locale->parse_date_to_object($::form->{ob_date})      }
551
sub init_cb_startdate   { $::locale->parse_date_to_object($::form->{cb_startdate}) }
552
sub init_cb_date        { $::locale->parse_date_to_object($::form->{cb_date})      }
553

  
315 554
1;
SL/DB/MetaSetup/Default.pm
30 30
  bin_id                                    => { type => 'integer' },
31 31
  bin_id_ignore_onhand                      => { type => 'integer' },
32 32
  businessnumber                            => { type => 'text' },
33
  carry_over_account_chart_id               => { type => 'integer' },
33 34
  closedto                                  => { type => 'date' },
34 35
  cnnumber                                  => { type => 'text' },
35 36
  co_ustid                                  => { type => 'text' },
......
100 101
  itime                                     => { type => 'timestamp', default => 'now()' },
101 102
  language_id                               => { type => 'integer' },
102 103
  letternumber                              => { type => 'integer' },
104
  loss_carried_forward_chart_id             => { type => 'integer' },
103 105
  max_future_booking_interval               => { type => 'integer', default => 360 },
104 106
  mtime                                     => { type => 'timestamp' },
105 107
  normalize_part_descriptions               => { type => 'boolean', default => 'true' },
......
114 116
  pdonumber                                 => { type => 'text' },
115 117
  ponumber                                  => { type => 'text' },
116 118
  precision                                 => { type => 'numeric', default => '0.01', not_null => 1, precision => 15, scale => 5 },
119
  profit_carried_forward_chart_id           => { type => 'integer' },
117 120
  profit_determination                      => { type => 'text' },
118 121
  project_status_id                         => { type => 'integer' },
119 122
  project_type_id                           => { type => 'integer' },
......
195 198
    key_columns => { bin_id_ignore_onhand => 'id' },
196 199
  },
197 200

  
201
  carry_over_account_chart => {
202
    class       => 'SL::DB::Chart',
203
    key_columns => { carry_over_account_chart_id => 'id' },
204
  },
205

  
198 206
  currency => {
199 207
    class       => 'SL::DB::Currency',
200 208
    key_columns => { currency_id => 'id' },
201 209
  },
202 210

  
211
  loss_carried_forward_chart => {
212
    class       => 'SL::DB::Chart',
213
    key_columns => { loss_carried_forward_chart_id => 'id' },
214
  },
215

  
216
  profit_carried_forward_chart => {
217
    class       => 'SL::DB::Chart',
218
    key_columns => { profit_carried_forward_chart_id => 'id' },
219
  },
220

  
203 221
  project_status => {
204 222
    class       => 'SL::DB::ProjectStatus',
205 223
    key_columns => { project_status_id => 'id' },
doc/changelog
25 25
  die aus Workflows aus dem Quellauftrag entstanden sind, gleich dem Betrag
26 26
  des Quellauftrags ist.
27 27

  
28
- Der Jahresabschluß wurde komplett überarbeitet, es wird nun zwischen
29
  Bestands- und Erfolgskonten unterschieden und ein Gewinn- bzw. Verlustvortrag
30
  übertragen.
31

  
28 32
Kleinere neue Features und Detailverbesserungen:
29 33

  
30 34
- Mahnungen nach Abteilung filtern
locale/de/all
14 14
  ' bytes, max='                => ' Bytes, Maximum=',
15 15
  ' missing!'                   => ' fehlt!',
16 16
  '#1 (custom variable)'        => '#1 (benutzerdefinierte Variable)',
17
  '#1 CB transactions and #1 OB transactions generated.' => '#1 Schluss- und #1 Eröffnungsbuchungen wurden erstellt.',
18 17
  '#1 MD'                       => '#1 PT',
19 18
  '#1 additional part(s)'       => '#1 zusätzliche(r) Artikel',
20 19
  '#1 bank transaction bookings undone.' => '#1 Bankbewegung(en) rückgängig gemacht',
......
307 306
  'Apply to transfers without bin' => 'Bei allen Lagerbewegungen ohne Lagerplatz setzen',
308 307
  'Apply to transfers without comment' => 'Bei allen Lagerbewegungen ohne Kommentar setzen',
309 308
  'Apply to transfers without warehouse' => 'Bei allen Lagerbewegungen ohne Lager setzen',
309
  'Apply year-end bookings'     => 'Jahresabschlußbuchungen durchführen',
310 310
  'Applying #1:'                => 'Führe #1 aus:',
311 311
  'Approximately #1 prices will be updated.' => 'Ungefähr #1 Preise werden aktualisiert.',
312 312
  'Apr'                         => 'Apr',
313 313
  'April'                       => 'April',
314 314
  'Ar aging on %s'              => 'Offene Forderungen zum %s',
315
  'Are you sure to generate cb/ob transactions?' => 'Sollen die EB/SB Buchungen wirklich erzeugt werden?',
316 315
  'Are you sure you want to delete Invoice Number' => 'Soll die Rechnung mit folgender Nummer wirklich gelöscht werden:',
317 316
  'Are you sure you want to delete this letter?' => 'Sind Sie sicher, dass Sie diesen Brief löschen wollen?',
318 317
  'Are you sure you want to remove the marked entries from the queue?' => 'Sind Sie sicher, dass die markierten Einträge von der Warteschlange gelöscht werden sollen?',
......
356 355
  'Attachment name'             => 'Name des Anhangs',
357 356
  'Attachments'                 => 'Dateianhänge',
358 357
  'Attempt to call an undefined sub named \'%s\'' => 'Es wurde versucht, eine nicht definierte Unterfunktion namens \'%s\' aufzurufen.',
359
  'Attention: Here will be generated a lot of CB/OB transactions.' => 'Hiermit werden Buchungen für den Schlussbestand (SB-Buchung) und den Eröffnungsbestand (EB-Buchung) für mehrere Konten gleichzeitig gebucht.<br>In diesem Schritt wird das Datum der Buchungen sowie das Saldovortragskonto festgelegt.<br>Das Datum der SB-Buchung wird außerdem verwendet um das Saldo der Konten zu ermitteln, welche im nächsten Schritt (nach "Weiter") angezeigt werden.',
360 358
  'Audit Control'               => 'Bücherkontrolle',
361 359
  'Aug'                         => 'Aug',
362 360
  'August'                      => 'August',
......
389 387
  'Background jobs and task server' => 'Hintergrund-Jobs und Task-Server',
390 388
  'Balance'                     => 'Bilanz',
391 389
  'Balance Sheet'               => 'Bilanz',
390
  'Balance accounts'            => 'Bestandskonten',
392 391
  'Balance sheet date'          => 'Bilanzstichtag',
393 392
  'Balance startdate method'    => 'Methode zur Ermittlung des Startdatums für Bilanz',
393
  'Balance with CB'             => 'Saldo mit SB',
394 394
  'Balances'                    => 'Salden',
395 395
  'Balancing'                   => 'Bilanzierung',
396 396
  'Bank'                        => 'Bank',
......
495 495
  'CANCELED'                    => 'Storniert',
496 496
  'CB Transaction'              => 'SB-Buchung',
497 497
  'CB Transactions'             => 'SB-Buchungen',
498
  'CB date #1 is higher than OB date #2. Please select again.' => 'SB-Datum #1 ist größer als EB-Datum #2. Bitte sinnvollere Werte auswählen.',
499
  'CB/OB Transactions'          => 'SB/EB buchen',
500 498
  'CN'                          => 'Kd-Nr.',
501 499
  'CR'                          => 'H',
502 500
  'CSS style for pictures'      => 'CSS Style für Bilder',
......
569 567
  'Cannot transfer negative quantities.' => 'Negative Mengen können nicht ausgelagert werden.',
570 568
  'Cannot transfer. <br> Reason:<br>#1' => 'Kann nicht ein-/auslagern. <br>Grund:<br>#1',
571 569
  'Cannot unlink payment for a closed period!' => 'Ein oder alle Bankbewegungen befinden sich innerhalb einer geschloßenen Periode. ',
570
  'Carry over account for year-end closing' => 'Saldenvortragskonto',
572 571
  'Carry over shipping address' => 'Lieferadresse übernehmen',
573 572
  'Cash'                        => 'Zahlungsverkehr',
574 573
  'Cash accounting'             => 'Ist-Versteuerung',
......
639 638
  'Close Window'                => 'Fenster Schließen',
640 639
  'Close window'                => 'Fenster schließen',
641 640
  'Closed'                      => 'Geschlossen',
641
  'Closing Balance'             => 'Abschlußsaldo',
642 642
  'Collective Orders only work for orders from one customer!' => 'Sammelaufträge funktionieren nur für Aufträge von einem Kunden!',
643 643
  'Column name'                 => 'Spaltenname',
644 644
  'Comma'                       => 'Komma',
......
1263 1263
  'Error message from the database: #1' => 'Fehlermeldung der Datenbank: #1',
1264 1264
  'Error message from the webshop api:' => 'Fehlermeldung der Webshop Api',
1265 1265
  'Error when saving: #1'       => 'Fehler beim Speichern: #1',
1266
  'Error while applying year-end bookings!' => 'Fehler beim Durchführen der Abschlußbuchungen!',
1266 1267
  'Error with default taxzone'  => 'Ungültige Standardsteuerzone',
1267 1268
  'Error!'                      => 'Fehler!',
1268 1269
  'Error: #1'                   => 'Fehler: #1',
......
1846 1847
  'Long Description (quotations & orders)' => 'Langtext (Angebote & Aufträge)',
1847 1848
  'Long Description for invoices' => 'Langtext für Rechnungen',
1848 1849
  'Long Description for quotations & orders' => 'Langtext für Angebote & Aufträge',
1850
  'Loss'                        => 'Verlust',
1851
  'Loss carried forward account' => 'Verlustvortragskonto',
1849 1852
  'Luxembourg'                  => 'Luxemburg',
1850 1853
  'MAILED'                      => 'Gesendet',
1851 1854
  'MD'                          => 'PT',
......
1991 1994
  'No bank information has been entered in this customer\'s master data entry. You cannot create bank collections unless you enter bank information.' => 'Für diesen Kunden wurden in seinen Stammdaten keine Kontodaten hinterlegt. Solange dies nicht geschehen ist, können Sie keine Überweisungen für den Lieferanten anlegen.',
1992 1995
  'No bank information has been entered in this vendor\'s master data entry. You cannot create bank transfers unless you enter bank information.' => 'Für diesen Lieferanten wurden in seinen Stammdaten keine Kontodaten hinterlegt. Solange dies nicht geschehen ist, können Sie keine Überweisungen für den Lieferanten anlegen.',
1993 1996
  'No bins have been added to this warehouse yet.' => 'Es wurden zu diesem Lager noch keine Lagerplätze angelegt.',
1997
  'No carry-over chart configured!' => 'Kein Saldenvortragskonto konfiguriert!',
1994 1998
  'No changes since previous version.' => 'Keine Änderungen seit der letzten Version.',
1995 1999
  'No clients have been created yet.' => 'Es wurden noch keine Mandanten angelegt.',
1996 2000
  'No contact selected to delete' => 'Keine Ansprechperson zum Löschen ausgewählt',
......
2027 2031
  'No print templates have been created for this client yet. Please do so in the client configuration.' => 'Für diesen Mandanten wurden noch keine Druckvorlagen angelegt. Bitte holen Sie dies in der Mandantenkonfiguration nach.',
2028 2032
  'No printers have been created yet.' => 'Es wurden noch keine Drucker angelegt.',
2029 2033
  'No problems were recognized.' => 'Es wurden keine Probleme gefunden.',
2034
  'No profit and loss carried forward chart configured!' => 'Kein Verlustvortragskonto konfiguriert!',
2035
  'No profit carried forward chart configured!' => 'Kein Gewinnvortragskonto konfiguriert!',
2030 2036
  'No quotations or orders have been created yet.' => 'Es wurden noch keine Angebote oder Aufträge angelegt.',
2031 2037
  'No report with id #1'        => 'Es gibt keinen Report mit der Id #1',
2032 2038
  'No requirement spec templates have been created yet.' => 'Es wurden noch keine Pflichtenheftvorlagen angelegt.',
2033 2039
  'No results.'                 => 'Keine Artikel',
2034
  'No revert available.'        => 'Dieser Vorgang kann nicht rückgängig gemacht werden, ggf. falsch erstellte Buchungen müssen einzeln manuell korrigiert werden.',
2035 2040
  'No search results found!'    => 'Keine Suchergebnisse gefunden!',
2036 2041
  'No sections created yet'     => 'Keine Abschnitte erstellt',
2037 2042
  'No sections have been created so far.' => 'Bisher wurden noch keine Abschnitte angelegt.',
......
2107 2112
  'Number pages'                => 'Seiten nummerieren',
2108 2113
  'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' => 'Zahlenvariablen: Mit \'PRECISION=n\' erzwingt man, dass Zahlen mit n Nachkommastellen formatiert werden.',
2109 2114
  'OB Transaction'              => 'EB-Buchung',
2110
  'OB Transactions'             => 'EB-Buchungen',
2111 2115
  'Objects have been imported.' => 'Objekte wurden importiert.',
2112 2116
  'Obsolete'                    => 'Ungültig',
2113 2117
  'Oct'                         => 'Okt',
......
2120 2124
  'On Hand'                     => 'Auf Lager',
2121 2125
  'On Order'                    => 'Ist bestellt',
2122 2126
  'On the next page the type of all variables can be set.' => 'Auf der folgenden Seite können die Typen aller Variablen gesetzt werden.',
2123
  'One OB-transaction'          => 'Eine EB-Buchung',
2124
  'One SB-transaction'          => 'Eine SB-Buchung',
2125 2127
  'One of the columns "qty" or "target_qty" must be given. If "target_qty" is given, the quantity to transfer for each transfer will be calculate, so that the quantity for this part, warehouse and bin will result in the given "target_qty" after each transfer.' => 'Eine der Spalten "qty" oder "target_qty" muss angegeben werden. Wird "target_qty" angegeben, so wird die zu bewegende Menge für jede Lagerbewegung so berechnet, dass die Lagermenge für diesen Artikel, Lager und Lagerplatz nach jeder Lagerbewegung der angegebenen Zielmenge entspricht.',
2126 2128
  'One or more Perl modules missing' => 'Ein oder mehr Perl-Module fehlen',
2127 2129
  'Onhand only sets the quantity in master data, not in inventory. This is only a legacy info field and will be overwritten as soon as a inventory transfer happens.' => 'Das Import-Feld Auf Lager setzt nur die Menge in den Stammdaten, nicht im Lagerbereich. Dies ist historisch gewachsen nur ein Informationsfeld was mit dem tatsächlichen Wert überschrieben wird, sobald eine wirkliche Lagerbewegung stattfindet (DB-Trigger).',
......
2298 2300
  'Please choose a part.'       => 'Bitte wählen Sie einen Artikel aus.',
2299 2301
  'Please choose for which categories the taxes should be displayed (otherwise remove the ticks):' => 'Bitte wählen Sie für welche Kontoart die Steuer angezeigt werden soll (ansonsten einfach die Häkchen entfernen)',
2300 2302
  'Please choose the action to be processed for your target quantity:' => 'Bitte wählen Sie eine Aktion, die mit Ihrer gezählten Zielmenge durchgeführt werden soll:',
2303
  'Please configure the carry over and profit and loss accounts for year-end closing in the client configuration!' => 'Bitte konfigurieren Sie in der Mandantenkonfiguration das Saldenvortragskonto, das Gewinnvortragskonto und das Verlustvortragskonto!',
2301 2304
  'Please contact your administrator or a service provider.' => 'Bitte kontaktieren Sie Ihren Administrator oder einen Dienstleister.',
2302 2305
  'Please contact your administrator.' => 'Bitte wenden Sie sich an Ihren Administrator.',
2303 2306
  'Please correct the settings and try again or deactivate that client.' => 'Bitte korrigieren Sie die Einstellungen und versuchen Sie es erneut, oder deaktivieren Sie diesen Mandanten.',
......
2443 2446
  'Production'                  => 'Produktion',
2444 2447
  'Production (typeabbreviation)' => 'P',
2445 2448
  'Productivity'                => 'Produktivität',
2449
  'Profit'                      => 'Gewinn',
2450
  'Profit and loss accounts'    => 'Erfolgskonten',
2451
  'Profit carried forward account' => 'Gewinnvortragskonto',
2446 2452
  'Profit determination'        => 'Gewinnermittlung',
2447 2453
  'Proforma Invoice'            => 'Proformarechnung',
2448 2454
  'Program'                     => 'Programm',
......
2687 2693
  'SEPA strings'                => 'SEPA-Überweisungen',
2688 2694
  'SQL query'                   => 'SQL-Abfrage',
2689 2695
  'SWIFT MT940 format'          => 'SWIFT-MT940-Format',
2690
  'Saldo'                       => 'Saldo',
2691 2696
  'Saldo Credit'                => 'Saldo Haben',
2692 2697
  'Saldo Debit'                 => 'Saldo Soll',
2693 2698
  'Saldo neu'                   => 'Saldo neu',
......
2790 2795
  'Select Mulit-Item Options'   => 'Multi-Treffer Auswahlliste',
2791 2796
  'Select a Customer'           => 'Endkunde auswählen',
2792 2797
  'Select a period'             => 'Bitte Zeitraum auswählen',
2793
  'Select charts for which the CB/OB transactions want to be posted.' => 'Wählen Sie Konten aus, zu welchen SB/EB-Buchungen erstellt werden sollen.',
2794 2798
  'Select federal state...'     => 'Bundesland auswählen...',
2795 2799
  'Select file to upload'       => 'Datei zum Hochladen auswählen',
2796 2800
  'Select from one of the items below' => 'Wählen Sie einen der untenstehenden Einträge',
......
2996 3000
  'Start of year'               => 'Jahresanfang',
2997 3001
  'Start process'               => 'Prozess starten',
2998 3002
  'Start the correction assistant' => 'Korrekturassistenten starten',
3003
  'Startdate method'            => 'Methode zur Ermittlung des Startdatums',
2999 3004
  'Startdate_coa'               => 'Gültig ab',
3000 3005
  'Starting Balance'            => 'Eröffnungsbilanzwerte',
3001 3006
  'Starting balance'            => 'Anfangssaldo',
......
3050 3055
  'Subtotals per quarter'       => 'Zwischensummen pro Quartal',
3051 3056
  'Such entries cannot be exported into the DATEV format and have to be fixed as well.' => 'Solche Einträge sind aber nicht DATEV-exportiertbar und müssen ebenfalls korrigiert werden.',
3052 3057
  'Suggested invoice'           => 'Rechnungsvorschlag',
3053
  'Sum CB Transactions'         => 'Summe SB',
3054 3058
  'Sum Credit'                  => 'Summe Haben',
3055 3059
  'Sum Debit'                   => 'Summe Soll',
3056
  'Sum OB Transactions'         => 'Summe EB',
3057 3060
  'Sum for'                     => 'Summe für',
3058 3061
  'Sum for #1'                  => 'Summe für #1',
3059 3062
  'Sum for section'             => 'Summe für Abschnitt',
......
3512 3515
  'There was an error saving the draft' => 'Beim Speichern des Entwurfs ist ein Fehler aufgetretetn',
3513 3516
  'There was an error saving the letter' => 'Ein Fehler ist aufgetreten. Der Brief konnte nicht gespeichert werden.',
3514 3517
  'There was an error saving the letter draft' => 'Ein Fehler ist aufgetreten. Der Briefentwurf konnte nicht gespeichert werden.',
3515
  'There will be two transactions done:' => 'Zu jedem ausgewählten Konto werden jeweils zwei Buchungen erstellt:',
3516 3518
  'There you can let kivitendo create the basic tables for you, even in an already existing database.' => 'Dort können Sie kivitendo diese grundlegenden Tabellen erstellen lassen, selbst in einer bereits existierenden Datenbank.',
3517 3519
  'Therefore several settings that had to be made for each user in the past have been consolidated into the client configuration.' => 'Dazu wurden gewisse Einstellungen, die vorher bei jedem Benutzer vorgenommen werden mussten, in die Konfiguration eines Mandanten verschoben.',
3518 3520
  'Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.' => 'So ist die Definition von "kg" mit der Basiseinheit "g" und dem Faktor 1000 zulässig, die Definition von "g" mit der Basiseinheit "kg" und dem Faktor "0,001" hingegen nicht.',
......
3598 3600
  'Time estimate'               => 'Zeitschätzung',
3599 3601
  'Time period for the analysis:' => 'Analysezeitraum:',
3600 3602
  'Time/cost estimate actions'  => 'Aktionen für Kosten-/Zeitabschätzung',
3601
  'Timerange'                   => 'Zeitraum',
3602 3603
  'Timestamp'                   => 'Uhrzeit',
3603 3604
  'Tired of copying always nice phrases for this message? Click here to use the new preset message option!' => 'Müde vom vielen Copy & Paste aus vorherigen Anschreiben? Hier klicken, um E-Mail-Texte vorzudefinieren!',
3604 3605
  'Title'                       => 'Titel',
......
3904 3905
  'X'                           => 'X',
3905 3906
  'YYYY'                        => 'JJJJ',
3906 3907
  'Year'                        => 'Jahr',
3908
  'Year-end bookings were successfully completed!' => 'Die Jahresabschlußbuchungen wurden erfolgreich durchgeführt!',
3909
  'Year-end closing'            => 'Jahresabschluß',
3910
  'Year-end date'               => 'Jahresabschlußdatum',
3911
  'Year-end date missing'       => '',
3907 3912
  'Yearly'                      => 'jährlich',
3908 3913
  'Yearly taxreport not yet implemented' => 'Jährlicher Steuerreport für dieses Ausgabeformat noch nicht implementiert',
3909 3914
  'Yes'                         => 'Ja',
......
4005 4010
  'cleared'                     => 'Abgeglichen',
4006 4011
  'click here to edit cvars'    => 'Klicken Sie hier, um nach benutzerdefinierten Variablen zu suchen',
4007 4012
  'close'                       => 'schließen',
4008
  'close chart'                 => 'Saldovortragskonto',
4009 4013
  'closed'                      => 'geschlossen',
4010 4014
  'companylogo_subtitle'        => 'Lizenziert für',
4011 4015
  'config/kivitendo.conf: Key "DB_config" is missing.' => 'config/kivitendo.conf: Das Schlüsselwort "DB_config" fehlt.',
......
4065 4069
  'from \'#1\' imported Files'  => 'Von \'#1\' importierte Dateien',
4066 4070
  'from (time)'                 => 'von',
4067 4071
  'general_ledger_list'         => 'Buchungsjournal',
4068
  'generate cb/ob transactions for selected charts' => 'Start-/Endbuchungen für ausgewählte Konten erstellen',
4069 4072
  'generated Files'             => 'Erzeugte Dokumente',
4070 4073
  'gobd-#1-#2.zip'              => 'gobd-#1-#2.zip',
4071 4074
  'h'                           => 'h',
menus/user/00-erp.yaml
634 634
  params:
635 635
    action: GoBD/filter
636 636
- parent: general_ledger
637
  id: general_ledger_cbob_transactions
638
  name: CB/OB Transactions
637
  id: year_end_closing
638
  name: Year-end closing
639 639
  icon: cbob
640 640
  order: 470
641 641
  access: general_ledger
642 642
  params:
643
    action: YearEndTransactions/filter
643
    action: YearEndTransactions/form
644 644
- parent: general_ledger
645 645
  id: general_ledger_reports
646 646
  name: Reports
sql/Pg-upgrade2/defaults_year_end_charts.sql
1
-- @tag: defaults_year_end_charts
2
-- @description: Standardkonten für Jahresabschluß
3
-- @depends: release_3_5_4
4

  
5
ALTER TABLE defaults ADD COLUMN carry_over_account_chart_id     INTEGER REFERENCES chart(id);
6
ALTER TABLE defaults ADD COLUMN profit_carried_forward_chart_id INTEGER REFERENCES chart(id);
7
ALTER TABLE defaults ADD COLUMN loss_carried_forward_chart_id   INTEGER REFERENCES chart(id);
templates/webpages/client_config/_default_accounts.html
60 60
   <td>[% P.chart.picker('defaults.workflow_po_ap_chart_id', SELF.defaults.workflow_po_ap_chart_id, type='AP_amount', choose=1, style=style) %]<td>
61 61
  </tr>
62 62

  
63
  <tr>
64
    <th align="right">[% LxERP.t8("Year-end closing") %]</th>
65
  </tr>
66
  <tr>
67
   <td align="right">[% LxERP.t8("Carry over account for year-end closing") %]</td>
68
   <td>[% P.chart.picker('defaults.carry_over_account_chart_id', SELF.defaults.carry_over_account_chart_id, category='A', choose=1, style=style) %]<td>
69
  </tr>
70

  
71
  <tr>
72
   <td align="right">[% LxERP.t8("Profit carried forward account") %]</td>
73
   <td>[% P.chart.picker('defaults.profit_carried_forward_chart_id', SELF.defaults.profit_carried_forward_chart_id, category='A', choose=1, style=style) %]<td>
74
  </tr>
75

  
76
  <tr>
77
   <td align="right">[% LxERP.t8("Loss carried forward account") %]</td>
78
   <td>[% P.chart.picker('defaults.loss_carried_forward_chart_id', SELF.defaults.loss_carried_forward_chart_id, category='A', choose=1, style=style) %]<td>
79
  </tr>
63 80
</table>
64 81
</div>
templates/webpages/gl/yearend_bottom.html
1
[%- USE L %]
2
[%- USE LxERP %]
3
    [%- L.hidden_tag("cb_date",SELF.cb_date.to_kivitendo) %]
4
    [%- L.hidden_tag("cb_startdate",SELF.cb_startdate.to_kivitendo) %]
5
    [%- L.hidden_tag("cb_reference",SELF.cb_reference) %]
6
    [%- L.hidden_tag("cb_description",SELF.cb_description) %]
7
    [%- L.hidden_tag("ob_date",SELF.ob_date.to_kivitendo) %]
8
    [%- L.hidden_tag("ob_reference",SELF.ob_reference) %]
9
    [%- L.hidden_tag("ob_description",SELF.ob_description) %]
10
    [%- L.hidden_tag("cbob_chart",SELF.cbob_chart) %]
11
    [%- L.hidden_tag("rowcount",SELF.row_count) %]
12
</form>
templates/webpages/gl/yearend_filter.html
1
[%- USE HTML %]
2
[%- USE T8 %]
3
[%- USE L %]
4
[%- USE LxERP %]
5

  
6
<h1>[% title | html %]</h1>
7

  
8
[%- INCLUDE 'common/flash.html' %]
9

  
10
<form id='filter_form'>
11

  
12
<table>
13
  <tr>
14
    <td width="20px"></td>
15
    <td align="left" colspan="5">[% 'Attention: Here will be generated a lot of CB/OB transactions.' | $T8 %]</td>
16
  </tr>
17
  <tr>
18
    <td><p></p></td>
19
  </tr>
20
  <tr>
21
    <th></th>
22
    <th width="400px" colspan="2" align="center">[% 'CB Transactions' | $T8 %]</th>
23
    <th width="400px"colspan="2" align="center">[% 'OB Transactions' | $T8 %]</th>
24
    <th>&nbsp;</th>
25
  </tr>
26
  <tr>
27
    <td></td>
28
    <td align="right">[% 'Date' | $T8 %]</td>
29
    <td>[% L.date_tag('cb_date', SELF.cb_date) %]</td>
30
    <td align="right">[% 'Date' | $T8 %]</td>
31
    <td>[% L.date_tag('ob_date', SELF.ob_date) %]</td>
32
    <td></td>
33
  </tr>
34
  <tr>
35
    <td></td>
36
    <td align="right">[% 'Reference' | $T8 %]</td>
37
    <td>[% L.input_tag('cb_reference', SELF.cb_reference) %]</td>
38
    <td align="right">[% 'Reference' | $T8 %]</td>
39
    <td>[% L.input_tag('ob_reference', SELF.ob_reference) %]</td>
40
    <td></td>
41
  </tr>
42
  <tr>
43
    <td></td>
44
    <td align="right">[% 'Description' | $T8 %]</td>
45
    <td>[% L.input_tag('cb_description', SELF.cb_description) %]</td>
46
    <td align="right">[% 'Description' | $T8 %]</td>
47
    <td>[% L.input_tag('ob_description', SELF.ob_description) %]</td>
48
    <td></td>
49
  </tr>
50
  <tr>
51
    <td><p></p></td>
52
  </tr>
53
  <tr>
54
    <th colspan="2"></th>
55
    <th align=right>[% 'close chart' | $T8 %]</th>
56
    <td colspan="3">[% L.select_tag('cbob_chart', SELF.charts9000, title_sub=\make_title_of_chart, default=SELF.cbob_chart, style="width: 400px") %]</td>
57
  </tr>
58
</table>
59
</form>
templates/webpages/gl/yearend_top.html
1
[%- USE LxERP %]
2
<form method="post" action="controller.pl" id="form">
3
<table>
4
  <tr>
5
    <td width="20px"></td>
6
    <td colspan="6" align="left">
7
      [%- LxERP.t8('Select charts for which the CB/OB transactions want to be posted.') %]<br>
8
      [%- LxERP.t8('There will be two transactions done:') %]<br>
9
     - [%- LxERP.t8('One SB-transaction') %] ( [% SELF.cb_date.to_kivitendo %], [% SELF.cb_reference %], [% SELF.cb_description %], [% SELF.cbob_chartaccno %] )<br>
10
     - [%- LxERP.t8('One OB-transaction') %] ( [% SELF.ob_date.to_kivitendo %], [% SELF.ob_reference %], [% SELF.ob_description %], [% SELF.cbob_chartaccno %] )<br>
11
      [%- LxERP.t8('No revert available.') %]
12
    </td>
13
  </tr>
14
  <tr>
15
    <td><p></p></td>
16
  </tr>
17
  <tr>
18
    <th></th>
19
    <th align="right">[% LxERP.t8('close chart') %]</th>
20
    <td>[% SELF.cbob_chartaccno %]</td>
21
  </tr>
22
</table>
templates/webpages/yearend/_charts.html
1
[%- USE LxERP -%]
2
[%- USE T8    -%]
3
[%- USE L     -%]
4
[%- USE HTML  -%]
5
[%- USE P     -%]
6

  
7

  
8
[%- SET dec = 2 %]
9

  
10
<h2>[% 'Balance accounts' | $T8 %]</h2>
11
<table cellpadding="3px">
12
 <tr class="listheading">
13
  <th            >[%- 'Account'          | $T8 %]</th>
14
  <th            >[%- 'Description'      | $T8 %]</th>
15
  <th colspan="2">[%- 'Starting Balance' | $T8 %]</th>
16
  <th colspan="2">[%- 'Balance with CB'  | $T8 %]</th>
17
  <th colspan="2">[%- 'Closing Balance'  | $T8 %]</th>
18
 </tr>
19
 <tr class="listheading">
20
  <th></th>
21
  <th></th>
22
  <th>[%- 'Debit'  | $T8 %]</th>
23
  <th>[%- 'Credit' | $T8 %]</th>
24
  <th>[%- 'Debit'  | $T8 %]</th>
25
  <th>[%- 'Credit' | $T8 %]</th>
26
  <th>[%- 'Debit'  | $T8 %]</th>
27
  <th>[%- 'Credit' | $T8 %]</th>
28
 </tr>
29
 [% FOREACH chart = charts %]
30
   [%- NEXT UNLESS chart.account_type == 'asset_account' -%]
31
 <tr id="tr_[% loop.count %]" class="listrow[% loop.count % 2 %]">
32
  <td>                 [% chart.accno | html %]</td>
33
  <td>                 [% chart.description | html %]</td>
34
  <td class="numeric"> [% IF chart.ob_amount < 0      %]  [% LxERP.format_amount(chart.ob_amount * -1, dec)       %] [% END %]</td>
35
  <td class="numeric"> [% IF chart.ob_amount > 0      %]  [% LxERP.format_amount(chart.ob_amount, dec)            %] [% END %]</td>
36
  <td class="numeric"> [% IF chart.amount_with_cb < 0 %]  [% LxERP.format_amount(chart.amount_with_cb * -1, dec)  %] [% END %]</td>
37
  <td class="numeric"> [% IF chart.amount_with_cb > 0 %]  [% LxERP.format_amount(chart.amount_with_cb, dec)       %] [% END %]</td>
38
  [% # cb amounts: >/< are switched and cb_amounts are multiplied with -1. The closing balance as calculated by cb_amount negates the actual balance, but when displaying it as the closing balance we want to display it in the same form as the actual balance %]
39
  <td class="numeric"> [% IF chart.cb_amount > 0 %]  [% LxERP.format_amount(chart.cb_amount *  1, dec) %] [% END %]</td>
40
  <td class="numeric"> [% IF chart.cb_amount < 0 %]  [% LxERP.format_amount(chart.cb_amount * -1, dec) %] [% END %]</td>
41
 </tr>
42
 [% END %]
43
</table>
44

  
45
<h2>[% 'Profit and loss accounts' | $T8 %]</h2>
46

  
47
<p>
48
[% IF profit_loss_sum < 0 %] [% THEN %][% 'Loss' | $T8 %] [% ELSE %] [% 'Profit' | $T8 %] [% END %]:   
49
[% LxERP.format_amount(profit_loss_sum, dec) %]
50
</p>
51

  
52
<table cellpadding="3px">
53
 <tr class="listheading">
54
  <th          >[%- 'Account'         | $T8 %]</th>
55
  <th          >[%- 'Description'     | $T8 %]</th>
56
  <th colspan=2>[%- 'Balance with CB' | $T8 %]</th>
57
  <th colspan=2>[%- 'Closing Balance' | $T8 %]</th>
58
 </tr>
59
 <tr class="listheading">
60
  <th></th>
61
  <th></th>
62
  <th>[%- 'Debit'  | $T8 %]</th>
63
  <th>[%- 'Credit' | $T8 %]</th>
64
  <th>[%- 'Debit'  | $T8 %]</th>
65
  <th>[%- 'Credit' | $T8 %]</th>
66
 </tr>
67
 [% FOREACH chart = charts %]
68
   [%- NEXT UNLESS chart.account_type == 'profit_loss_account' -%]
69
 <tr id="tr_[% loop.count %]" class="listrow[% loop.count % 2 %]">
70
  <td                >[% chart.accno | html %]</td>
71
  <td                >[% chart.description | html %]</td>
72
  <td class="numeric">[% IF chart.amount_with_cb < 0 %] [% LxERP.format_amount(chart.amount_with_cb * -1, dec) %] [% END %]</td>
73
  <td class="numeric">[% IF chart.amount_with_cb > 0 %] [% LxERP.format_amount(chart.amount_with_cb, dec)      %] [% END %]</td>
74
  <td class="numeric">[% IF chart.cb_amount > 0 %] [% LxERP.format_amount(chart.cb_amount *  1, dec) %] [% END %]</td>
75
  <td class="numeric">[% IF chart.cb_amount < 0 %] [% LxERP.format_amount(chart.cb_amount * -1, dec)      %] [% END %]</td>
76
 </tr>
77
 [% END %]
78
</table>
79
[% # L.dump(charts) %]
templates/webpages/yearend/form.html
1
[%- USE HTML %]
2
[%- USE T8 %]
3
[%- USE L %]
4
[%- USE LxERP %]
5

  
6
<h1>[% title | html %]</h1>
7

  
8
[%- INCLUDE 'common/flash.html' %]
9

  
10
[% IF carry_over_chart AND profit_chart AND loss_chart %] [% THEN %]
11
<form id="filter" name="filter" method="post" action="controller.pl">
12
<table>
13
  <tr>
14
    <td align="right">[% 'Year-end date' | $T8 %]</td>
15
    <td>[% L.date_tag('cb_date', SELF.cb_date) %]</td>
16
  </tr>
17
  <tr class="startdate">
18
   <td align="right">[% 'Startdate method' | $T8 %]</td>
19
   <td>[% L.select_tag('balance_startdate_method', balance_startdate_method_options, value_key = 'value', title_key = 'title') %]</td>
20
  </tr>
21
  <tr class="startdate">
22
    <td align="right">[% 'Start date' | $T8 %]</td>
23
    <td>[% L.date_tag('cb_startdate', '', readonly=1) %]</td>
24
  </tr>
25
  <tr>
26
    <td align="right">[% 'Carry over account for year-end closing' | $T8 %]</td>
27
    <td>[% carry_over_chart.displayable_name | html %]</td>
28
  </tr>
29
  <tr>
30
    <td align="right">[% 'Profit carried forward account' | $T8 %]</td>
31
    <td>[% profit_chart.displayable_name | html %]</td>
32
  </tr>
33
  <tr>
34
    <td align="right">[% 'Loss carried forward account' | $T8 %]</td>
35
    <td>[% loss_chart.displayable_name | html %]</td>
36
  </tr>
37
</table>
38
</form>
39
[% ELSE %]
40
  [% 'Please configure the carry over and profit and loss accounts for year-end closing in the client configuration!' | $T8 %]
41
[% END %]
42

  
43
[% # L.button_tag("refresh_charts();", LxERP.t8("Preview")) %]
44
[% L.button_tag("year_end_bookings();", LxERP.t8("Apply year-end bookings"), id='apply_year_end_bookings_button', confirm=LxERP.t8("Are you sure?")) %]
45

  
46
<div id="charts" style="padding-top: 20px">
47
</div>
48

  
49
<script type="text/javascript">
50

  
51
  function get_startdate() {
52
    $.get("controller.pl", {
53
      action:                   'YearEndTransactions/get_start_date',
54
      cb_date:                  $('#cb_date').val(),
55
      balance_startdate_method: $('#balance_startdate_method').val()
56
    }, kivi.eval_json_result)
57
  }
58

  
59
  function year_end_bookings() {
60
    $.post("controller.pl", {
61
      action:  'YearEndTransactions/year_end_bookings',
62
      cb_date: $('#cb_date').val(),
63
    }, kivi.eval_json_result)
64
  }
65

  
66
  function refresh_charts() {
67
    var filterdata = $('#filter').serialize()
68
    var url = './controller.pl?action=YearEndTransactions/update_charts&' + filterdata;
69
    $.ajax({
70
       url : url,
71
       type: 'GET',
72
       success: function(data){
73
           $('#charts').html(data);
74
       }
75
    })
76
  };
77

  
78
$(function(){
79

  
80
  $('#apply_year_end_bookings_button').hide();
81
  $('.startdate').hide();
82

  
83
  $('#balance_startdate_method').change(function(){
84
    get_startdate();
85
    setTimeout(function() {
86
      refresh_charts();
87
    }, 200);    
88
  });
89

  
90
  $('#cb_date').change(function(){
91
    get_startdate();
92
    setTimeout(function() {
93
      refresh_charts();
94
    }, 200);    
95
  });
96
})
97

  
98
</script>

Auch abrufbar als: Unified diff