Moved parsing of amount with decimal separator to Converter object

This commit is contained in:
Robert Horlings 2016-01-17 15:37:49 +01:00
parent 323c16ebe1
commit 4909fcc8b4
3 changed files with 36 additions and 6 deletions

View 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;
}
}

View File

@ -26,8 +26,6 @@ class AbnAmroDescription
*/
public function fix()
{
$this->handleAmount();
// Try to parse the description in known formats.
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
@ -55,10 +53,6 @@ class AbnAmroDescription
$this->row = $row;
}
protected function handleAmount() {
$this->data['amount'] = floatval(str_replace(',', '.', $this->row[6]));
}
/**
* Parses the current description in SEPA format
* @return boolean true if the description is SEPA format, false otherwise

View File

@ -177,6 +177,12 @@ return [
'converter' => 'Amount',
'field' => 'amount',
],
'amount-comma-separated' => [
'name' => 'Amount (comma as decimal separator)',
'mappable' => false,
'converter' => 'AmountComma',
'field' => 'amount',
],
'sepa-ct-id' => [
'name' => 'SEPA Credit Transfer end-to-end ID',
'mappable' => false,