-# The following subs are more or less copied/pasted from SL::DB::Helper::PriceTaxCalculator.
-sub _linetotal {
- my ($order, $item) = @_;
-
- # bb: todo: currencies are not handled by now
- my $exchangerate = _get_exchangerate($order);
-
- my $num_dec = max 2, _num_decimal_places($item->sellprice);
- my $discount = _round($item->sellprice * ($item->discount || 0), $num_dec);
- my $sellprice = _round($item->sellprice - $discount, $num_dec);
- my $linetotal = _round($sellprice * $item->qty / $item->price_factor, 2 ) * $exchangerate;
- $linetotal = _round($linetotal, 2 );
-
- return $linetotal;
-}
-
-sub _get_exchangerate {
- my ($order) = @_;
- require SL::DB::Default;
-
- my $exchangerate = 1;
- my $currency = $order->currency_id ? $order->currency->name || '' : '';
- if ($currency ne SL::DB::Default->get_default_currency) {
- $exchangerate = $::form->check_exchangerate(\%::myconfig, $currency, $order->transdate, $order->is_sales ? 'buy' : 'sell');
- }
-
- return $exchangerate;
-}
-
-sub _num_decimal_places {
- return length( (split(/\./, '' . ($_[0] * 1), 2))[1] || '' );
-}
-
-sub _round {
- return $::form->round_amount(@_);
-}
-