Revision 64b3d19a
Von Rolf Fluehmann vor mehr als 8 Jahren hinzugefügt
SL/DB/Invoice.pm | ||
---|---|---|
249 | 249 |
|
250 | 250 |
my $worker = sub { |
251 | 251 |
my %data = $self->calculate_prices_and_taxes; |
252 |
my $grossamount = $self->amount; |
|
253 |
$self->amount($::form->round_amount($grossamount, 2, 1)); |
|
254 |
my $rounding = $::form->round_amount( |
|
255 |
$self->amount - $grossamount, |
|
256 |
2 |
|
257 |
); |
|
252 | 258 |
|
253 | 259 |
$self->_post_create_assemblyitem_entries($data{assembly_items}); |
254 | 260 |
$self->save; |
... | ... | |
256 | 262 |
$self->_post_add_acctrans($data{amounts_cogs}); |
257 | 263 |
$self->_post_add_acctrans($data{amounts}); |
258 | 264 |
$self->_post_add_acctrans($data{taxes}); |
259 |
|
|
260 | 265 |
$self->_post_add_acctrans({ $params{ar_id} => $self->amount * -1 }); |
261 | 266 |
|
262 | 267 |
$self->_post_update_allocated($data{allocated}); |
268 |
|
|
269 |
$self->_post_book_rounding($rounding); |
|
263 | 270 |
}; |
264 | 271 |
|
265 | 272 |
if ($self->db->in_transaction) { |
... | ... | |
296 | 303 |
} |
297 | 304 |
} |
298 | 305 |
|
306 |
sub _post_book_rounding { |
|
307 |
my ($self, $rounding) = @_; |
|
308 |
|
|
309 |
my $tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id; |
|
310 |
my $rnd_accno = $rounding == 0 ? 0 |
|
311 |
: $rounding > 0 ? SL::DB::Default->get->rndgain_accno_id |
|
312 |
: SL::DB::Default->get->rndloss_accno_id |
|
313 |
; |
|
314 |
if ($rnd_accno != 0) { |
|
315 |
SL::DB::AccTransaction->new(trans_id => $self->id, |
|
316 |
chart_id => $rnd_accno, |
|
317 |
amount => $rounding, |
|
318 |
tax_id => $tax_id, |
|
319 |
taxkey => 0, |
|
320 |
project_id => $self->globalproject_id, |
|
321 |
transdate => $self->transdate, |
|
322 |
chart_link => $rnd_accno)->save; |
|
323 |
} |
|
324 |
} |
|
325 |
|
|
299 | 326 |
sub add_ar_amount_row { |
300 | 327 |
my ($self, %params ) = @_; |
301 | 328 |
|
Auch abrufbar als: Unified diff
added roundings for periodic invoices