From 02ba4e7a63f45723a274083225ce87530dfe0a52 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 23 Jun 2016 16:53:23 +0200 Subject: [PATCH] Payment Helper exchangerate Methode verbessert --- SL/DB/Helper/Payment.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 42bf4c263..660794428 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -657,11 +657,13 @@ sub exchangerate { return 1 if $self->currency_id == $::instance_conf->get_currency_id; + die "transdate isn't a DateTime object:" . ref($self->transdate) unless ref($self->transdate) eq 'DateTime'; my $rate = SL::DB::Manager::Exchangerate->find_by(currency_id => $self->currency_id, transdate => $self->transdate, ); return undef unless $rate; - $self->is_sales ? return $rate->sell : return $rate->buy; + + return $self->is_sales ? $rate->buy : $rate->sell; # also undef if not defined }; sub get_payment_suggestions { @@ -1106,8 +1108,12 @@ values for sales and purchases. =item C -Returns the exchangerate in database format for the invoice according to that invoice's transdate. -Returns 'sell' for sales, 'buy' for purchases. +Returns 1 immediately if the record uses the default currency. + +Returns the exchangerate in database format for the invoice according to that +invoice's transdate, returning 'buy' for sales, 'sell' for purchases. + +If no exchangerate can be found for that day undef is returned. =back -- 2.20.1