mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Moved parsing of amount with decimal separator to Converter object
This commit is contained in:
30
app/Helpers/Csv/Converter/AmountComma.php
Normal file
30
app/Helpers/Csv/Converter/AmountComma.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Helpers\Csv\Converter;
|
||||||
|
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AmountComma
|
||||||
|
*
|
||||||
|
* Parses the input as the amount with a comma as decimal separator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Helpers\Csv\Converter
|
||||||
|
*/
|
||||||
|
class AmountComma extends BasicConverter implements ConverterInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Account|null
|
||||||
|
*/
|
||||||
|
public function convert()
|
||||||
|
{
|
||||||
|
$value = str_replace(",", ".", $this->value );
|
||||||
|
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
return floatval($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -26,8 +26,6 @@ class AbnAmroDescription
|
|||||||
*/
|
*/
|
||||||
public function fix()
|
public function fix()
|
||||||
{
|
{
|
||||||
$this->handleAmount();
|
|
||||||
|
|
||||||
// Try to parse the description in known formats.
|
// Try to parse the description in known formats.
|
||||||
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
|
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
|
||||||
|
|
||||||
@@ -55,10 +53,6 @@ class AbnAmroDescription
|
|||||||
$this->row = $row;
|
$this->row = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleAmount() {
|
|
||||||
$this->data['amount'] = floatval(str_replace(',', '.', $this->row[6]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the current description in SEPA format
|
* Parses the current description in SEPA format
|
||||||
* @return boolean true if the description is SEPA format, false otherwise
|
* @return boolean true if the description is SEPA format, false otherwise
|
||||||
|
@@ -177,6 +177,12 @@ return [
|
|||||||
'converter' => 'Amount',
|
'converter' => 'Amount',
|
||||||
'field' => 'amount',
|
'field' => 'amount',
|
||||||
],
|
],
|
||||||
|
'amount-comma-separated' => [
|
||||||
|
'name' => 'Amount (comma as decimal separator)',
|
||||||
|
'mappable' => false,
|
||||||
|
'converter' => 'AmountComma',
|
||||||
|
'field' => 'amount',
|
||||||
|
],
|
||||||
'sepa-ct-id' => [
|
'sepa-ct-id' => [
|
||||||
'name' => 'SEPA Credit Transfer end-to-end ID',
|
'name' => 'SEPA Credit Transfer end-to-end ID',
|
||||||
'mappable' => false,
|
'mappable' => false,
|
||||||
|
Reference in New Issue
Block a user