mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Parse floats to user formatted versions in exports
This commit is contained in:
parent
c67c73ca01
commit
8192a48816
@ -347,14 +347,30 @@ class BaseTransformer
|
||||
*/
|
||||
public function getFloat($data, $field)
|
||||
{
|
||||
if (array_key_exists($field, $data)) {
|
||||
return Number::parseFloat($data[$field]);
|
||||
if (array_key_exists($field, $data)) {\
|
||||
return $this->parseStringToFloat($data, $field);
|
||||
// return Number::parseFloat($data[$field]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
private function parseStringToFloat($data, $field): float
|
||||
{
|
||||
|
||||
$currency = $this->company->currency();
|
||||
|
||||
$amount = preg_replace('/[^\d,.-]/', '', $data[$field]);
|
||||
|
||||
$amount = str_replace($currency->thousand_separator, '', $amount);
|
||||
|
||||
$amount = $currency->decimal_separator !== '.' ? str_replace($currency->decimal_separator, '.', $amount) : $amount;
|
||||
|
||||
return (float) $amount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $field
|
||||
|
Loading…
Reference in New Issue
Block a user