mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Refactor some code for recurrences.
This commit is contained in:
@@ -112,7 +112,7 @@ class AccountFactory
|
||||
$data['currency_id'] = $currency->id;
|
||||
// remove virtual balance when not an asset account or a liability
|
||||
$canHaveVirtual = [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
|
||||
if (!\in_array($type->type, $canHaveVirtual, true)) {
|
||||
if (!in_array($type->type, $canHaveVirtual, true)) {
|
||||
$databaseData['virtual_balance'] = '0';
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class AccountFactory
|
||||
$return = Account::create($databaseData);
|
||||
$this->updateMetaData($return, $data);
|
||||
|
||||
if (\in_array($type->type, $canHaveVirtual, true)) {
|
||||
if (in_array($type->type, $canHaveVirtual, true)) {
|
||||
if ($this->validIBData($data)) {
|
||||
$this->updateIB($return, $data);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class BillFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $billId
|
||||
* @param int|null $billId
|
||||
* @param null|string $billName
|
||||
*
|
||||
* @return Bill|null
|
||||
@@ -126,8 +126,10 @@ class BillFactory
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
$query = sprintf('%%%s%%', $name);
|
||||
/** @var Bill $first */
|
||||
$first = $this->user->bills()->where('name', 'LIKE', $query)->first();
|
||||
|
||||
return $this->user->bills()->where('name', 'LIKE', $query)->first();
|
||||
return $first;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -246,6 +246,10 @@ class TransactionJournalFactory
|
||||
$destinationAccount = $this->getAccount($type->type, 'destination', (int)$row['destination_id'], $row['destination_name']);
|
||||
|
||||
/** double check currencies. */
|
||||
$sourceCurrency = $currency;
|
||||
$destCurrency = $currency;
|
||||
$sourceForeignCurrency = $foreignCurrency;
|
||||
$destForeignCurrency = $foreignCurrency;
|
||||
|
||||
if ($type->type === 'Withdrawal') {
|
||||
// make sure currency is correct.
|
||||
|
||||
Reference in New Issue
Block a user