Some more last-minute fixes.

This commit is contained in:
James Cole
2019-08-09 20:33:57 +02:00
parent b09504d0f7
commit a248544641
7 changed files with 20 additions and 41 deletions

View File

@@ -177,7 +177,12 @@ class TransactionFactory
}
// @codeCoverageIgnoreEnd
if (null !== $result) {
Log::debug(sprintf('Created transaction #%d (%s %s), part of journal #%d', $result->id, $this->currency->code, $amount, $this->journal->id));
Log::debug(
sprintf(
'Created transaction #%d (%s %s, account %s), part of journal #%d', $result->id, $this->currency->code, $amount, $this->account->name,
$this->journal->id
)
);
// do foreign currency thing: add foreign currency info to $one and $two if necessary.
if (null !== $this->foreignCurrency && null !== $foreignAmount && $this->foreignCurrency->id !== $this->currency->id) {

View File

@@ -287,7 +287,7 @@ class TransactionJournalFactory
$destForeignCurrency = $foreignCurrency;
}
if ('Transfer' === $type->type) {
if (TransactionType::TRANSFER === $type->type) {
// get currencies
$currency = $this->getCurrency($currency, $sourceAccount);
$foreignCurrency = $this->getCurrency($foreignCurrency, $destinationAccount);
@@ -298,6 +298,11 @@ class TransactionJournalFactory
$destForeignCurrency = $currency;
}
// if transfer, switch accounts:
if (TransactionType::TRANSFER === $type->type) {
[$sourceAccount, $destinationAccount] = [$destinationAccount, $sourceAccount];
}
/** Create a basic journal. */
$journal = TransactionJournal::create(
[