Revision 923c8609
Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt
SL/Controller/YearEndTransactions.pm | ||
---|---|---|
23 | 23 |
|
24 | 24 |
sub action_filter { |
25 | 25 |
my ($self) = @_; |
26 |
|
|
27 | 26 |
$self->ob_date(DateTime->today->truncate(to => 'year')) if !$self->ob_date; |
28 | 27 |
$self->cb_date(DateTime->today->truncate(to => 'year')->add(days => -1)) if !$self->cb_date; |
29 |
$self->ob_reference(t8('OB Transaction')) if !$self->ob_reference; |
|
30 |
$self->cb_reference(t8('CB Transaction')) if !$self->cb_reference; |
|
28 |
$self->ob_reference(t8('OB Transaction')) if !$self->ob_reference;
|
|
29 |
$self->cb_reference(t8('CB Transaction')) if !$self->cb_reference;
|
|
31 | 30 |
$self->ob_description(t8('OB Transaction')) if !$self->ob_description; |
32 | 31 |
$self->cb_description(t8('CB Transaction')) if !$self->cb_description; |
33 | 32 |
$self->render('gl/yearend_filter', |
34 |
title => t8('CB/OB Transactions'), |
|
33 |
title => t8('CB/OB Transactions'),
|
|
35 | 34 |
make_title_of_chart => sub { $_[0]->accno.' '.$_[0]->description } |
36 | 35 |
); |
37 | 36 |
|
... | ... | |
46 | 45 |
$self->prepare_report($report); |
47 | 46 |
|
48 | 47 |
$report->set_options( |
49 |
output_format => 'HTML', |
|
50 |
raw_top_info_text => $::form->parse_html_template('gl/yearend_top', { SELF => $self }), |
|
48 |
output_format => 'HTML',
|
|
49 |
raw_top_info_text => $::form->parse_html_template('gl/yearend_top', { SELF => $self }),
|
|
51 | 50 |
raw_bottom_info_text => $::form->parse_html_template('gl/yearend_bottom', { SELF => $self }), |
52 |
allow_pdf_export => 0, |
|
53 |
allow_csv_export => 0, |
|
54 |
title => $::locale->text('CB/OB Transactions'), |
|
55 |
);
|
|
51 |
allow_pdf_export => 0,
|
|
52 |
allow_csv_export => 0,
|
|
53 |
title => $::locale->text('CB/OB Transactions'),
|
|
54 |
); |
|
56 | 55 |
$report->generate_with_headers(); |
57 | 56 |
$main::lxdebug->leave_sub(); |
58 | 57 |
} |
... | ... | |
105 | 104 |
my ($self,$report) = @_; |
106 | 105 |
$main::lxdebug->enter_sub(); |
107 | 106 |
my $idx = 1; |
108 |
my $cgi = $::request->{cgi}; |
|
109 | 107 |
|
110 | 108 |
my %column_defs = ( |
111 |
'ids' => { raw_header_data => $self->presenter->checkbox_tag("", id => "check_all",
|
|
112 |
checkall => "[data-checkall=1]"), 'align' => 'center' },
|
|
113 |
'chart' => { text => $::locale->text('Account'), },
|
|
114 |
'description' => { text => $::locale->text('Description'), },
|
|
115 |
'saldo' => { text => $::locale->text('Saldo'), 'align' => 'right'},
|
|
116 |
'sum_cb' => { text => $::locale->text('Sum CB Transactions'), 'align' => 'right'}, ##close == Schluss
|
|
117 |
'sum_ob' => { text => $::locale->text('Sum OB Transactions'), 'align' => 'right'}, ##open == Eingang
|
|
109 |
'ids' => { raw_header_data => $self->presenter->checkbox_tag("", id => "check_all", |
|
110 |
checkall => "[data-checkall=1]"), 'align' => 'center' }, |
|
111 |
'chart' => { text => $::locale->text('Account'), }, |
|
112 |
'description' => { text => $::locale->text('Description'), }, |
|
113 |
'saldo' => { text => $::locale->text('Saldo'), 'align' => 'right'}, |
|
114 |
'sum_cb' => { text => $::locale->text('Sum CB Transactions'), 'align' => 'right'}, ##close == Schluss |
|
115 |
'sum_ob' => { text => $::locale->text('Sum OB Transactions'), 'align' => 'right'}, ##open == Eingang |
|
118 | 116 |
); |
119 |
my @columns = qw(ids chart description saldo sum_cb sum_ob); |
|
117 |
my @columns = qw(ids chart description saldo sum_cb sum_ob);
|
|
120 | 118 |
map { $column_defs{$_}->{visible} = 1 } @columns; |
121 |
my $ob_next_date = $::locale->parse_date_to_object($self->ob_date)->add(years => 1)->add(days => -1)->to_kivitendo; |
|
122 | 119 |
|
123 |
$self->cb_startdate($self->get_balance_starting_date($self->cb_date)); |
|
120 |
my $ob_next_date = $self->ob_date->clone(); |
|
121 |
$ob_next_date->add(years => 1)->add(days => -1); |
|
122 |
|
|
123 |
$self->cb_startdate($::locale->parse_date_to_object($self->get_balance_starting_date($self->cb_date))); |
|
124 | 124 |
|
125 | 125 |
my @custom_headers = (); |
126 | 126 |
# Zeile 1: |
127 | 127 |
push @custom_headers, [ |
128 | 128 |
{ 'text' => ' ', 'colspan' => 3 }, |
129 |
{ 'text' => $::locale->text("Timerange")."<br />".$self->cb_startdate." - ".$self->cb_date, 'colspan' => 2, 'align' => 'center'},
|
|
130 |
{ 'text' => $::locale->text("Timerange")."<br />".$self->ob_date." - ".$ob_next_date, 'align' => 'center'},
|
|
129 |
{ 'text' => $::locale->text("Timerange")."<br />".$self->cb_startdate->to_kivitendo." - ".$self->cb_date->to_kivitendo, 'colspan' => 2, 'align' => 'center'},
|
|
130 |
{ 'text' => $::locale->text("Timerange")."<br />".$self->ob_date->to_kivitendo." - ".$ob_next_date->to_kivitendo, 'align' => 'center'},
|
|
131 | 131 |
]; |
132 | 132 |
|
133 | 133 |
# Zeile 2: |
... | ... | |
148 | 148 |
my $chart_id = $chart->id; |
149 | 149 |
my $row = { map { $_ => { 'data' => '' } } @columns }; |
150 | 150 |
$row->{ids} = { |
151 |
'raw_data' => $self->presenter->checkbox_tag("multi_id_${idx}", value => $chart_id, "data-checkall" => 1),
|
|
151 |
'raw_data' => $self->presenter->checkbox_tag("multi_id_${idx}", value => $chart_id, "data-checkall" => 1), |
|
152 | 152 |
'valign' => 'center', |
153 | 153 |
'align' => 'center', |
154 | 154 |
}; |
155 |
$row->{chart}->{data} = $chart->accno;
|
|
156 |
$row->{description}->{data} = $chart->description;
|
|
155 |
$row->{chart}->{data} = $chart->accno; |
|
156 |
$row->{description}->{data} = $chart->description; |
|
157 | 157 |
if ( $balance > 0 ) { |
158 | 158 |
$row->{saldo}->{data} = $::form->format_amount(\%::myconfig, $balance, 2)." H"; |
159 | 159 |
} elsif ( $balance < 0 ) { |
... | ... | |
162 | 162 |
$row->{saldo}->{data} = $::form->format_amount(\%::myconfig,0, 2)." "; |
163 | 163 |
} |
164 | 164 |
my $sum_cb = 0; |
165 |
foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id => $chart->id, cb_transaction => 't', |
|
165 |
foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id => $chart->id, cb_transaction => 't',
|
|
166 | 166 |
transdate => { ge => $self->cb_startdate}, |
167 |
transdate => { le => $self->cb_date }]) }) { |
|
167 |
transdate => { le => $self->cb_date } |
|
168 |
]) }) { |
|
168 | 169 |
$sum_cb += $acc->amount; |
169 | 170 |
} |
170 | 171 |
my $sum_ob = 0; |
171 |
foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id => $chart->id, ob_transaction => 't', |
|
172 |
foreach my $acc ( @{ SL::DB::Manager::AccTransaction->get_all(where => [ chart_id => $chart->id, ob_transaction => 't',
|
|
172 | 173 |
transdate => { ge => $self->ob_date}, |
173 |
transdate => { le => $ob_next_date }]) }) { |
|
174 |
transdate => { le => $ob_next_date } |
|
175 |
]) }) { |
|
174 | 176 |
$sum_ob += $acc->amount; |
175 | 177 |
} |
176 | 178 |
if ( $sum_cb > 0 ) { |
... | ... | |
200 | 202 |
$main::lxdebug->enter_sub(); |
201 | 203 |
my ($self,$chart) = @_; |
202 | 204 |
|
203 |
## eigene Abfrage da SL:DB:Chart->get_balance keine cb_transactions mitzählt |
|
204 |
## Alternative in Chart cb_transaction abfrage per neuem Parameter 'with_cb' disablen: |
|
205 |
# my %balance_params = ( fromdate => $self->startdate, |
|
206 |
# todate => $self->cb_date, |
|
207 |
# accounting_method => 'accrual', |
|
208 |
# with_cb => 1, ## in Chart cb_transaction abfrage disablen |
|
209 |
# ); |
|
210 |
# return $chart->get_balance(%balance_params); |
|
211 |
|
|
212 |
$main::lxdebug->message(LXDebug->DEBUG2(),"get_balance from=".$self->cb_startdate." to=".$self->cb_date); |
|
213 |
my $query = qq|SELECT SUM(amount) AS sum FROM acc_trans WHERE chart_id = ? | . |
|
214 |
qq| AND transdate >= ? AND transdate <= ? |; |
|
215 |
my @query_args = ( $chart->id, $self->cb_startdate, $self->cb_date); |
|
216 |
my ($balance) = selectfirst_array_query($::form, $chart->db->dbh, $query, @query_args); |
|
217 |
|
|
205 |
#$main::lxdebug->message(LXDebug->DEBUG2(),"get_balance from=".$self->cb_startdate->to_kivitendo." to=".$self->cb_date->to_kivitendo); |
|
206 |
my $balance = $chart->get_balance(fromdate => $self->cb_startdate, todate => $self->cb_date); |
|
218 | 207 |
$main::lxdebug->leave_sub(); |
219 | 208 |
return 0 unless $balance != 0; |
220 | 209 |
return $balance; |
... | ... | |
225 | 214 |
$::form->get_employee(); |
226 | 215 |
my $employee_id = $::form->{employee_id}; |
227 | 216 |
$main::lxdebug->message(LXDebug->DEBUG2(),"employee_id=".$employee_id." ob=".$ob." cb=".$cb); |
228 |
my $gl_entry = SL::DB::GLTransaction->new(); |
|
229 |
$gl_entry->assign_attributes( |
|
230 |
employee_id => $employee_id, |
|
231 |
transdate => $transdate, |
|
232 |
reference => $reference, |
|
233 |
description => $description, |
|
217 |
my $gl_entry = SL::DB::GLTransaction->new( |
|
218 |
employee_id => $employee_id, |
|
219 |
transdate => $transdate, |
|
220 |
reference => $reference, |
|
221 |
description => $description, |
|
234 | 222 |
ob_transaction => $ob, |
235 | 223 |
cb_transaction => $cb, |
236 | 224 |
); |
237 |
$gl_entry->save; |
|
238 |
my $kto_trans1 = SL::DB::AccTransaction->new(); |
|
239 |
$kto_trans1->assign_attributes( |
|
240 |
trans_id => $gl_entry->id, |
|
241 |
transdate => $transdate, |
|
225 |
#$gl_entry->save; |
|
226 |
my $kto_trans1 = SL::DB::AccTransaction->new( |
|
227 |
trans_id => $gl_entry->id, |
|
228 |
transdate => $transdate, |
|
242 | 229 |
ob_transaction => $ob, |
243 | 230 |
cb_transaction => $cb, |
244 | 231 |
chart_id => $gegenkonto->id, |
... | ... | |
247 | 234 |
taxkey => 0, |
248 | 235 |
amount => $amount, |
249 | 236 |
); |
250 |
$kto_trans1->save; |
|
251 |
my $kto_trans2 = SL::DB::AccTransaction->new(); |
|
252 |
$kto_trans2->assign_attributes( |
|
253 |
trans_id => $gl_entry->id, |
|
254 |
transdate => $transdate, |
|
237 |
#$kto_trans1->save; |
|
238 |
my $kto_trans2 = SL::DB::AccTransaction->new( |
|
239 |
trans_id => $gl_entry->id, |
|
240 |
transdate => $transdate, |
|
255 | 241 |
ob_transaction => $ob, |
256 | 242 |
cb_transaction => $cb, |
257 | 243 |
chart_id => $konto->id, |
... | ... | |
260 | 246 |
taxkey => 0, |
261 | 247 |
amount => -$amount, |
262 | 248 |
); |
263 |
$kto_trans2->save; |
|
249 |
#$kto_trans2->save; |
|
250 |
$gl_entry->add_transactions($kto_trans1); |
|
251 |
$gl_entry->add_transactions($kto_trans2); |
|
252 |
$gl_entry->save; |
|
264 | 253 |
} |
265 | 254 |
|
266 |
sub init_cbob_chart { $::form->{cbob_chart} }
|
|
267 |
sub init_ob_date { $::form->{ob_date} }
|
|
268 |
sub init_ob_reference { $::form->{ob_reference} }
|
|
269 |
sub init_ob_description { $::form->{ob_description} } |
|
270 |
sub init_cb_startdate { $::form->{cb_startdate} }
|
|
271 |
sub init_cb_date { $::form->{cb_date} }
|
|
272 |
sub init_cb_reference { $::form->{cb_reference} }
|
|
273 |
sub init_cb_description { $::form->{cb_description} } |
|
255 |
sub init_cbob_chart { $::form->{cbob_chart} }
|
|
256 |
sub init_ob_date { $::locale->parse_date_to_object($::form->{ob_date}) }
|
|
257 |
sub init_ob_reference { $::form->{ob_reference} }
|
|
258 |
sub init_ob_description { $::form->{ob_description} }
|
|
259 |
sub init_cb_startdate { $::locale->parse_date_to_object($::form->{cb_startdate}) }
|
|
260 |
sub init_cb_date { $::locale->parse_date_to_object($::form->{cb_date}) }
|
|
261 |
sub init_cb_reference { $::form->{cb_reference} }
|
|
262 |
sub init_cb_description { $::form->{cb_description} }
|
|
274 | 263 |
|
275 |
sub init_charts9000 {
|
|
264 |
sub init_charts9000 { |
|
276 | 265 |
SL::DB::Manager::Chart->get_all( query => [ accno => { like => '9%'}] ); |
277 | 266 |
} |
278 | 267 |
|
279 |
sub init_charts {
|
|
268 |
sub init_charts { |
|
280 | 269 |
# wie geht 'not like' in rose ? |
281 | 270 |
SL::DB::Manager::Chart->get_all( query => [ \ "accno not like '9%'"], sort_by => 'accno ASC' ); |
282 | 271 |
} |
Auch abrufbar als: Unified diff
Erstellen von Jahresabschluss-Buchungen(4)
- Einrückungen von G.Richardson,
- dates in DateObjekte konvertiert
- Eine Buchung und Gegenbuchung als eine Transaktion