mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Moved parsing of amount with decimal separator to Converter object
This commit is contained in:
parent
323c16ebe1
commit
4909fcc8b4
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()
|
||||
{
|
||||
$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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user