Files
firefly-iii/app/Import/Converter/BankDebitCredit.php

61 lines
1.7 KiB
PHP
Raw Normal View History

2016-07-16 07:58:25 +02:00
<?php
/**
2019-01-27 21:23:18 +01:00
* BankDebitCredit.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
2016-07-16 07:58:25 +02:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-10-21 08:40:00 +02:00
*
* This program is distributed in the hope that it will be useful,
2017-10-21 08:40:00 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-10-21 08:40:00 +02:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-07-16 07:58:25 +02:00
*/
2019-01-27 21:23:18 +01:00
declare(strict_types=1);
2016-07-16 07:58:25 +02:00
namespace FireflyIII\Import\Converter;
2019-01-27 21:23:18 +01:00
2016-07-16 07:58:25 +02:00
use Log;
/**
2019-01-27 21:23:18 +01:00
*
* Class BankDebitCredit
2016-07-16 07:58:25 +02:00
*/
2019-01-27 21:23:18 +01:00
class BankDebitCredit implements ConverterInterface
2016-07-16 07:58:25 +02:00
{
2019-01-27 21:23:18 +01:00
2016-07-16 07:58:25 +02:00
/**
2019-01-27 21:23:18 +01:00
* Convert a value.
2018-07-22 15:08:56 +02:00
*
2019-01-27 21:23:18 +01:00
* @return mixed
2016-07-16 07:58:25 +02:00
*
2019-01-27 21:23:18 +01:00
* @param $value
2016-07-16 07:58:25 +02:00
*/
public function convert($value): int
{
Log::debug('Going to convert ', ['value' => $value]);
2019-01-27 21:23:18 +01:00
$negative = [
'D', // Old style Rabobank (NL). Short for "Debit"
'A', // New style Rabobank (NL). Short for "Af"
2019-05-11 05:32:09 +02:00
'DR', // https://old.reddit.com/r/FireflyIII/comments/bn2edf/generic_debitcredit_indicator/
2019-01-27 21:23:18 +01:00
'Af', // ING (NL).
'Debet', // Triodos (NL)
2019-11-18 17:39:25 +01:00
'S', // "Soll", German term for debit
2019-01-27 21:23:18 +01:00
];
2019-06-21 19:10:02 +02:00
if (in_array(trim($value), $negative, true)) {
return -1;
}
2016-07-16 07:58:25 +02:00
return 1;
}
2019-02-09 10:36:59 +01:00
}