2016-07-16 07:58:25 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
2019-01-27 21:23:18 +01:00
|
|
|
* BankDebitCredit.php
|
2020-02-05 05:53:12 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-07-16 07:58:25 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* 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
|
|
|
*
|
2019-10-02 06:37:26 +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
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +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
|
|
|
|
2017-04-09 07:44:22 +02: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
|
2020-03-17 15:03:08 +01:00
|
|
|
*
|
2020-03-15 15:31:51 +01:00
|
|
|
* @deprecated
|
|
|
|
|
* @codeCoverageIgnore
|
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
|
|
|
*
|
2020-03-17 15:03:08 +01:00
|
|
|
* @param $value
|
|
|
|
|
*
|
2020-03-25 07:03:23 +01:00
|
|
|
* @return int
|
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
|
Add Debit to Generic Debit Credit indicator converter
Example CSV export from Community America, a Credit Union in the US:
``` csv
12/11/19,Five Guys,Sale FIVE GUYS,14.51,Debit,Food & Dining,Fast Food,CC1,,,false
12/11/19,Interest Income,Interest Earned,0.01,Credit,Income,Interest Income,Regular Savings,,Interest Earned,false
```
"Debit" is used instead of negative values in the amount column.
2019-12-15 19:06:44 -06:00
|
|
|
'Debit', // Community America (US)
|
2019-01-27 21:23:18 +01:00
|
|
|
];
|
2019-06-21 19:10:02 +02:00
|
|
|
if (in_array(trim($value), $negative, true)) {
|
2018-05-10 09:10:16 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
2016-07-16 07:58:25 +02:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2019-02-09 10:36:59 +01:00
|
|
|
}
|