X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/04caff2d7309da75f53424675795addff173f32c..49707e3c:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 9aa17adec..99c2e11ad 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -260,6 +260,8 @@ sub post { $self->_post_add_acctrans({ $params{ar_id} => $self->amount * -1 }); $self->_post_update_allocated($data{allocated}); + + $self->_post_book_rounding($data{rounding}); }; if ($self->db->in_transaction) { @@ -296,6 +298,26 @@ sub _post_add_acctrans { } } +sub _post_book_rounding { + my ($self, $rounding) = @_; + + my $tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id; + my $rnd_accno = $rounding == 0 ? 0 + : $rounding > 0 ? SL::DB::Default->get->rndgain_accno_id + : SL::DB::Default->get->rndloss_accno_id + ; + if ($rnd_accno != 0) { + SL::DB::AccTransaction->new(trans_id => $self->id, + chart_id => $rnd_accno, + amount => $rounding, + tax_id => $tax_id, + taxkey => 0, + project_id => $self->globalproject_id, + transdate => $self->transdate, + chart_link => $rnd_accno)->save; + } +} + sub add_ar_amount_row { my ($self, %params ) = @_;