X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=d2aa049274fe4dac1a4b4f74e8de5fa528650289;hb=0b33cc602d717933791d06cb64f65dea2a7c2354;hp=610f545eb117d911f9b7325bb0f766fba45a2d8e;hpb=1c181c11d5637d4388b138942f2edcd3c97e23c4;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 610f545eb..d2aa04927 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -951,6 +951,8 @@ sub round_amount { return 0 if !defined $amount; + $places //= 0; + if ($adjust) { my $precision = $::instance_conf->get_precision || 0.01; return $self->round_amount( $self->round_amount($amount / $precision, 0) * $precision, $places); @@ -2590,6 +2592,19 @@ sub all_vc { $main::lxdebug->leave_sub(); } +sub new_lastmtime { + my ($self, $table, $option) = @_; + + return unless $self->{id}; + croak ("wrong call, no valid table defined") unless $table =~ /^(oe|ar|ap|delivery_orders|parts)$/; + + my $query = "SELECT mtime, itime FROM " . $table . " WHERE id = ?"; + my $ref = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id}); + $ref->{mtime} ||= $ref->{itime}; + $self->{lastmtime} = $ref->{mtime}; + $main::lxdebug->message(LXDebug->DEBUG2(),"new lastmtime=".$self->{lastmtime}); +} + sub mtime_ischanged { my ($self, $table, $option) = @_; @@ -3658,11 +3673,12 @@ sub calculate_tax { my ($self,$amount,$taxrate,$taxincluded,$roundplaces) = @_; - $roundplaces = 2 unless defined $roundplaces; + $roundplaces //= 2; + $taxincluded //= 0; my $tax; - if ($taxincluded *= 1) { + if ($taxincluded) { # calculate tax (unrounded), subtract from amount, round amount and round tax $tax = $amount - ($amount / ($taxrate + 1)); # equivalent to: taxrate * amount / (taxrate + 1) $amount = $self->round_amount($amount - $tax, $roundplaces);