1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

checks for importing exchange rates

This commit is contained in:
David Bomba 2023-07-16 20:39:41 +10:00
parent 9bfaee5c1f
commit 6c3049f5cb
3 changed files with 17 additions and 2 deletions

View File

@ -319,6 +319,21 @@ class BaseTransformer
// return Number::parseFloat($number);
}
/**
* @param $data
* @param $field
*
* @return float
*/
public function getFloatOrOne($data, $field)
{
if (array_key_exists($field, $data))
return Number::parseStringFloat($data[$field]) > 0 ? Number::parseStringFloat($data[$field]) : 1;
return 1;
}
/**
* @param $name
*

View File

@ -114,7 +114,7 @@ class InvoiceTransformer extends BaseTransformer
$invoice_data,
'invoice.custom_surcharge4'
),
'exchange_rate' => $this->getFloat(
'exchange_rate' => $this->getFloatOrOne(
$invoice_data,
'invoice.exchange_rate'
),

View File

@ -114,7 +114,7 @@ class QuoteTransformer extends BaseTransformer
$quote_data,
'quote.custom_surcharge4'
),
'exchange_rate' => $this->getFloat(
'exchange_rate' => $this->getFloatOrOne(
$quote_data,
'quote.exchange_rate'
),