Add support for negated amount. Closes #1660 and #1650.

This commit is contained in:
HamuZ HamuZ
2018-09-09 13:35:21 +03:00
parent c83d93971f
commit 9df2d86ac2
7 changed files with 281 additions and 1 deletions

View File

@@ -74,7 +74,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
if ('_ignore' !== $role) {
++$assigned;
}
if (\in_array($role, ['amount', 'amount_credit', 'amount_debit'])) {
if (\in_array($role, ['amount', 'amount_credit', 'amount_debit', 'amount_negated'])) {
$hasAmount = true;
}
if ('foreign-currency-code' === $role) {

View File

@@ -27,6 +27,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Converter\Amount;
use FireflyIII\Import\Converter\AmountCredit;
use FireflyIII\Import\Converter\AmountDebit;
use FireflyIII\Import\Converter\AmountNegated;
use FireflyIII\Import\Converter\ConverterInterface;
use Log;
@@ -51,6 +52,8 @@ class ImportTransaction
public $amountCredit;
/** @var string */
public $amountDebit;
/** @var string */
public $amountNegated;
/** @var int */
public $billId;
/** @var string */
@@ -140,6 +143,7 @@ class ImportTransaction
'account-number' => 'accountNumber',
'amount_debit' => 'amountDebit',
'amount_credit' => 'amountCredit',
'amount_negated' => 'amountNegated',
'amount' => 'amount',
'amount_foreign' => 'foreignAmount',
'bill-name' => 'billName',
@@ -404,6 +408,11 @@ class ImportTransaction
$converterClass = AmountCredit::class;
$info['amount'] = $this->amountCredit;
}
if (null !== $this->amountNegated) {
Log::debug('Amount NEGATED value is not NULL, assume this is the correct value (overrules Amount and AmountDebit and AmountCredit).');
$converterClass = AmountNegated::class;
$info['amount'] = $this->amountNegated;
}
$info['class'] = $converterClass;
return $info;