X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FPriceTaxCalculator.pm;h=9a271841531d26e81f2a6283ab570a190833910f;hb=f30f0cce6468f895c7d59f3aab6e2a5731fc9705;hp=6afb45a4f5ab00d163264d62c6cecf871aee7786;hpb=abd56be11a58421b1d9401e812a83d28832b939a;p=kivitendo-erp.git diff --git a/SL/DB/Helper/PriceTaxCalculator.pm b/SL/DB/Helper/PriceTaxCalculator.pm index 6afb45a4f..9a2718415 100644 --- a/SL/DB/Helper/PriceTaxCalculator.pm +++ b/SL/DB/Helper/PriceTaxCalculator.pm @@ -40,7 +40,15 @@ sub calculate_prices_and_taxes { items => [ ], ); - _get_exchangerate($self, \%data, %params); + # set exchangerate in $data>{exchangerate} + if ( ref($self) eq 'SL::DB::Order' ) { + # orders store amount in the order currency + $data{exchangerate} = 1; + } else { + # invoices store amount in the default currency + _get_exchangerate($self, \%data, %params); + # $data{exchangerate} = $self->exchangerate; # untested alternative for setting exchangerate + }; $self->netamount( 0); $self->marge_total(0); @@ -104,7 +112,7 @@ sub _calculate_item { $item->marge_percent(0); } else { - my $lastcost = ! ($item->lastcost * 1) ? ($part->lastcost || 0) : $item->lastcost; + my $lastcost = !(($item->lastcost // 0) * 1) ? ($part->lastcost || 0) : $item->lastcost; $linetotal_cost = _round($lastcost * $item->qty / $item->marge_price_factor, 2); $item->marge_total( $linetotal - $linetotal_cost);