Make sure amounts are always positive.

This commit is contained in:
James Cole
2019-09-04 10:12:33 +02:00
parent d23656aac9
commit 2cda6eba94

View File

@@ -275,13 +275,10 @@ class TransactionGroupTransformer extends AbstractTransformer
// amount: // amount:
$type = $row['transaction_type_type'] ?? TransactionType::WITHDRAWAL; $type = $row['transaction_type_type'] ?? TransactionType::WITHDRAWAL;
$amount = $row['amount'] ?? '0'; $amount = app('steam')->positive($row['amount'] ?? '0');
if (TransactionType::WITHDRAWAL !== $type) {
$amount = bcmul($amount, '-1');
}
$foreignAmount = null; $foreignAmount = null;
if (null !== $row['foreign_amount']) { if (null !== $row['foreign_amount']) {
$foreignAmount = TransactionType::WITHDRAWAL !== $type ? bcmul($row['foreign_amount'], '-1') : $row['foreign_amount']; // @codeCoverageIgnore $foreignAmount = app('steam')->positive($row['foreign_amount']);
} }
$metaFieldData = $this->groupRepos->getMetaFields((int)$row['transaction_journal_id'], $this->metaFields); $metaFieldData = $this->groupRepos->getMetaFields((int)$row['transaction_journal_id'], $this->metaFields);