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

@@ -382,6 +382,7 @@ class ImportTransactionTest extends TestCase
'account-number' => 'accountNumber',
'amount_debit' => 'amountDebit',
'amount_credit' => 'amountCredit',
'amount_negated' => 'amountNegated',
'amount' => 'amount',
'amount_foreign' => 'foreignAmount',
'bill-name' => 'billName',
@@ -473,6 +474,38 @@ class ImportTransactionTest extends TestCase
$this->assertTrue(false, $e->getMessage());
}
}
/**
* Basic amount info. Should return something like '1.0'.
*
* @covers \FireflyIII\Support\Import\Placeholder\ImportTransaction
*/
public function testCalculateAmountNegatedPositive(): void
{
$importTransaction = new ImportTransaction;
$importTransaction->amountNegated = '1.56';
try {
$this->assertEquals('-1.56', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
/**
* Basic amount info. Should return something like '1.0'.
*
* @covers \FireflyIII\Support\Import\Placeholder\ImportTransaction
*/
public function testCalculateAmountNegatedNegative(): void
{
$importTransaction = new ImportTransaction;
$importTransaction->amountNegated = '-1.56';
try {
$this->assertEquals('1.56', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
/**
* With no amount data, object should return ''