mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 21:43:53 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -39,8 +38,6 @@ use Log;
|
||||
* @property User $user
|
||||
*
|
||||
* Trait CreateJournalsTrait
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
*/
|
||||
trait CreateJournalsTrait
|
||||
{
|
||||
@@ -54,7 +51,6 @@ trait CreateJournalsTrait
|
||||
abstract public function storeAccounts(User $user, TransactionType $type, array $data): array;
|
||||
|
||||
/**
|
||||
*
|
||||
* * Remember: a balancingAct takes at most one expense and one transfer.
|
||||
* an advancePayment takes at most one expense, infinite deposits and NO transfers.
|
||||
*
|
||||
@@ -71,7 +67,7 @@ trait CreateJournalsTrait
|
||||
foreach ($array as $name) {
|
||||
if (strlen(trim($name)) > 0) {
|
||||
$tag = Tag::firstOrCreateEncrypted(['tag' => $name, 'user_id' => $journal->user_id]);
|
||||
if (!is_null($tag)) {
|
||||
if (null !== $tag) {
|
||||
Log::debug(sprintf('Will try to connect tag #%d to journal #%d.', $tag->id, $journal->id));
|
||||
$tagRepository->connect($journal, $tag);
|
||||
}
|
||||
@@ -87,7 +83,7 @@ trait CreateJournalsTrait
|
||||
*/
|
||||
protected function storeBudgetWithTransaction(Transaction $transaction, int $budgetId)
|
||||
{
|
||||
if (intval($budgetId) > 0 && $transaction->transactionJournal->transactionType->type !== TransactionType::TRANSFER) {
|
||||
if (intval($budgetId) > 0 && TransactionType::TRANSFER !== $transaction->transactionJournal->transactionType->type) {
|
||||
/** @var \FireflyIII\Models\Budget $budget */
|
||||
$budget = Budget::find($budgetId);
|
||||
$transaction->budgets()->save($budget);
|
||||
@@ -123,7 +119,7 @@ trait CreateJournalsTrait
|
||||
|
||||
// store transaction one way:
|
||||
$amount = bcmul(strval($transaction['amount']), '-1');
|
||||
$foreignAmount = is_null($transaction['foreign_amount']) ? null : bcmul(strval($transaction['foreign_amount']), '-1');
|
||||
$foreignAmount = null === $transaction['foreign_amount'] ? null : bcmul(strval($transaction['foreign_amount']), '-1');
|
||||
$one = $this->storeTransaction(
|
||||
[
|
||||
'journal' => $journal,
|
||||
@@ -143,7 +139,7 @@ trait CreateJournalsTrait
|
||||
|
||||
// and the other way:
|
||||
$amount = strval($transaction['amount']);
|
||||
$foreignAmount = is_null($transaction['foreign_amount']) ? null : strval($transaction['foreign_amount']);
|
||||
$foreignAmount = null === $transaction['foreign_amount'] ? null : strval($transaction['foreign_amount']);
|
||||
$two = $this->storeTransaction(
|
||||
[
|
||||
'journal' => $journal,
|
||||
@@ -182,11 +178,10 @@ trait CreateJournalsTrait
|
||||
'identifier' => $data['identifier'],
|
||||
];
|
||||
|
||||
|
||||
if (is_null($data['foreign_currency_id'])) {
|
||||
if (null === $data['foreign_currency_id']) {
|
||||
unset($fields['foreign_currency_id']);
|
||||
}
|
||||
if (is_null($data['foreign_amount'])) {
|
||||
if (null === $data['foreign_amount']) {
|
||||
unset($fields['foreign_amount']);
|
||||
}
|
||||
|
||||
@@ -195,18 +190,17 @@ trait CreateJournalsTrait
|
||||
|
||||
Log::debug(sprintf('Transaction stored with ID: %s', $transaction->id));
|
||||
|
||||
if (!is_null($data['category'])) {
|
||||
if (null !== $data['category']) {
|
||||
$transaction->categories()->save($data['category']);
|
||||
}
|
||||
|
||||
if (!is_null($data['budget'])) {
|
||||
if (null !== $data['budget']) {
|
||||
$transaction->categories()->save($data['budget']);
|
||||
}
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $note
|
||||
@@ -215,16 +209,16 @@ trait CreateJournalsTrait
|
||||
*/
|
||||
protected function updateNote(TransactionJournal $journal, string $note): bool
|
||||
{
|
||||
if (strlen($note) === 0) {
|
||||
if (0 === strlen($note)) {
|
||||
$dbNote = $journal->notes()->first();
|
||||
if (!is_null($dbNote)) {
|
||||
if (null !== $dbNote) {
|
||||
$dbNote->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
$dbNote = $journal->notes()->first();
|
||||
if (is_null($dbNote)) {
|
||||
if (null === $dbNote) {
|
||||
$dbNote = new Note();
|
||||
$dbNote->noteable()->associate($journal);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -34,9 +33,7 @@ use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class JournalRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Class JournalRepository.
|
||||
*/
|
||||
class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
@@ -64,7 +61,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$messages->add('destination_account_expense', trans('firefly.invalid_convert_selection'));
|
||||
$messages->add('source_account_asset', trans('firefly.invalid_convert_selection'));
|
||||
|
||||
if ($source->id === $destination->id || is_null($source->id) || is_null($destination->id)) {
|
||||
if ($source->id === $destination->id || null === $source->id || null === $destination->id) {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
@@ -78,7 +75,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$journal->save();
|
||||
|
||||
// if journal is a transfer now, remove budget:
|
||||
if ($type->type === TransactionType::TRANSFER) {
|
||||
if (TransactionType::TRANSFER === $type->type) {
|
||||
$journal->budgets()->detach();
|
||||
}
|
||||
|
||||
@@ -117,7 +114,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
public function find(int $journalId): TransactionJournal
|
||||
{
|
||||
$journal = $this->user->transactionJournals()->where('id', $journalId)->first();
|
||||
if (is_null($journal)) {
|
||||
if (null === $journal) {
|
||||
return new TransactionJournal;
|
||||
}
|
||||
|
||||
@@ -157,7 +154,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users first transaction journal
|
||||
* Get users first transaction journal.
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
@@ -165,7 +162,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
$entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
|
||||
|
||||
if (is_null($entry)) {
|
||||
if (null === $entry) {
|
||||
return new TransactionJournal;
|
||||
}
|
||||
|
||||
@@ -187,7 +184,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function isTransfer(TransactionJournal $journal): bool
|
||||
{
|
||||
return $journal->transactionType->type === TransactionType::TRANSFER;
|
||||
return TransactionType::TRANSFER === $journal->transactionType->type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +197,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
Log::debug(sprintf('Going to reconcile transaction #%d', $transaction->id));
|
||||
$opposing = $this->findOpposingTransaction($transaction);
|
||||
|
||||
if (is_null($opposing)) {
|
||||
if (null === $opposing) {
|
||||
Log::debug('Opposing transaction is NULL. Cannot reconcile.');
|
||||
|
||||
return false;
|
||||
@@ -272,7 +269,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
'account' => $accounts['source'],
|
||||
'amount' => bcmul($amount, '-1'),
|
||||
'transaction_currency_id' => $data['currency_id'],
|
||||
'foreign_amount' => is_null($data['foreign_amount']) ? null : bcmul(strval($data['foreign_amount']), '-1'),
|
||||
'foreign_amount' => null === $data['foreign_amount'] ? null : bcmul(strval($data['foreign_amount']), '-1'),
|
||||
'foreign_currency_id' => $data['foreign_currency_id'],
|
||||
'description' => null,
|
||||
'category' => null,
|
||||
@@ -296,7 +293,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
$this->storeTransaction($two);
|
||||
|
||||
|
||||
// store tags
|
||||
if (isset($data['tags']) && is_array($data['tags'])) {
|
||||
$this->saveTags($journal, $data['tags']);
|
||||
@@ -329,14 +325,13 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function update(TransactionJournal $journal, array $data): TransactionJournal
|
||||
{
|
||||
|
||||
// update actual journal:
|
||||
$journal->description = $data['description'];
|
||||
$journal->date = $data['date'];
|
||||
$accounts = $this->storeAccounts($this->user, $journal->transactionType, $data);
|
||||
$data = $this->verifyNativeAmount($data, $accounts);
|
||||
$data['amount'] = strval($data['amount']);
|
||||
$data['foreign_amount'] = is_null($data['foreign_amount']) ? null : strval($data['foreign_amount']);
|
||||
$data['foreign_amount'] = null === $data['foreign_amount'] ? null : strval($data['foreign_amount']);
|
||||
|
||||
// unlink all categories, recreate them:
|
||||
$journal->categories()->detach();
|
||||
@@ -359,7 +354,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
}
|
||||
|
||||
// update note:
|
||||
if (isset($data['notes']) && !is_null($data['notes'])) {
|
||||
if (isset($data['notes']) && null !== $data['notes']) {
|
||||
$this->updateNote($journal, strval($data['notes']));
|
||||
}
|
||||
|
||||
@@ -401,11 +396,10 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$journal->budgets()->detach();
|
||||
|
||||
// update note:
|
||||
if (isset($data['notes']) && !is_null($data['notes'])) {
|
||||
if (isset($data['notes']) && null !== $data['notes']) {
|
||||
$this->updateNote($journal, strval($data['notes']));
|
||||
}
|
||||
|
||||
|
||||
// update meta fields:
|
||||
$result = $journal->save();
|
||||
if ($result) {
|
||||
@@ -434,7 +428,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
Log::debug(sprintf('Split journal update split transaction %d', $identifier));
|
||||
$transaction = $this->appendTransactionData($transaction, $data);
|
||||
$this->storeSplitTransaction($journal, $transaction, $identifier);
|
||||
$identifier++;
|
||||
++$identifier;
|
||||
}
|
||||
|
||||
$journal->save();
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -32,13 +31,10 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Interface JournalRepositoryInterface
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Interface JournalRepositoryInterface.
|
||||
*/
|
||||
interface JournalRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param TransactionType $type
|
||||
@@ -66,7 +62,7 @@ interface JournalRepositoryInterface
|
||||
public function delete(TransactionJournal $journal): bool;
|
||||
|
||||
/**
|
||||
* Find a specific journal
|
||||
* Find a specific journal.
|
||||
*
|
||||
* @param int $journalId
|
||||
*
|
||||
@@ -89,7 +85,7 @@ interface JournalRepositoryInterface
|
||||
public function findTransaction(int $transactionid): ?Transaction;
|
||||
|
||||
/**
|
||||
* Get users very first transaction journal
|
||||
* Get users very first transaction journal.
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -36,17 +35,13 @@ use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class JournalTasker
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Class JournalTasker.
|
||||
*/
|
||||
class JournalTasker implements JournalTaskerInterface
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@@ -128,7 +123,6 @@ class JournalTasker implements JournalTaskerInterface
|
||||
'foreign_currencies.decimal_places as foreign_currency_dp',
|
||||
'foreign_currencies.code as foreign_currency_code',
|
||||
'foreign_currencies.symbol as foreign_currency_symbol',
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
@@ -156,14 +150,14 @@ class JournalTasker implements JournalTaskerInterface
|
||||
'source_account_after' => bcadd($sourceBalance, $entry->amount),
|
||||
'destination_id' => $entry->destination_id,
|
||||
'destination_amount' => bcmul($entry->amount, '-1'),
|
||||
'foreign_destination_amount' => is_null($entry->foreign_amount) ? null : bcmul($entry->foreign_amount, '-1'),
|
||||
'foreign_destination_amount' => null === $entry->foreign_amount ? null : bcmul($entry->foreign_amount, '-1'),
|
||||
'destination_account_id' => $entry->destination_account_id,
|
||||
'destination_account_type' => $entry->destination_account_type,
|
||||
'destination_account_name' => Steam::decrypt(intval($entry->destination_account_encrypted), $entry->destination_account_name),
|
||||
'destination_account_before' => $destinationBalance,
|
||||
'destination_account_after' => bcadd($destinationBalance, bcmul($entry->amount, '-1')),
|
||||
'budget_id' => is_null($budget) ? 0 : $budget->id,
|
||||
'category' => is_null($category) ? '' : $category->name,
|
||||
'budget_id' => null === $budget ? 0 : $budget->id,
|
||||
'category' => null === $category ? '' : $category->name,
|
||||
'transaction_currency_id' => $entry->transaction_currency_id,
|
||||
'transaction_currency_code' => $entry->transaction_currency_code,
|
||||
'transaction_currency_symbol' => $entry->transaction_currency_symbol,
|
||||
@@ -173,15 +167,14 @@ class JournalTasker implements JournalTaskerInterface
|
||||
'foreign_currency_symbol' => $entry->foreign_currency_symbol,
|
||||
'foreign_currency_dp' => $entry->foreign_currency_dp,
|
||||
];
|
||||
if ($entry->destination_account_type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $entry->destination_account_type) {
|
||||
$transaction['destination_account_name'] = '';
|
||||
}
|
||||
|
||||
if ($entry->account_type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $entry->account_type) {
|
||||
$transaction['source_account_name'] = '';
|
||||
}
|
||||
|
||||
|
||||
$transactions[] = $transaction;
|
||||
}
|
||||
$cache->store($transactions);
|
||||
@@ -200,7 +193,7 @@ class JournalTasker implements JournalTaskerInterface
|
||||
/**
|
||||
* Collect the balance of an account before the given transaction has hit. This is tricky, because
|
||||
* the balance does not depend on the transaction itself but the journal it's part of. And of course
|
||||
* the order of transactions within the journal. So the query is pretty complex:
|
||||
* the order of transactions within the journal. So the query is pretty complex:.
|
||||
*
|
||||
* @param int $transactionId
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -28,9 +27,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface JournalTaskerInterface
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Interface JournalTaskerInterface.
|
||||
*/
|
||||
interface JournalTaskerInterface
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -34,9 +33,7 @@ use FireflyIII\User;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Trait SupportJournalsTrait
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Trait SupportJournalsTrait.
|
||||
*/
|
||||
trait SupportJournalsTrait
|
||||
{
|
||||
@@ -46,6 +43,7 @@ trait SupportJournalsTrait
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function storeAccounts(User $user, TransactionType $type, array $data): array
|
||||
@@ -73,17 +71,16 @@ trait SupportJournalsTrait
|
||||
throw new FireflyException(sprintf('Did not recognise transaction type "%s".', $type->type));
|
||||
}
|
||||
|
||||
if (is_null($accounts['source'])) {
|
||||
if (null === $accounts['source']) {
|
||||
Log::error('"source"-account is null, so we cannot continue!', ['data' => $data]);
|
||||
throw new FireflyException('"source"-account is null, so we cannot continue!');
|
||||
}
|
||||
|
||||
if (is_null($accounts['destination'])) {
|
||||
if (null === $accounts['destination']) {
|
||||
Log::error('"destination"-account is null, so we cannot continue!', ['data' => $data]);
|
||||
throw new FireflyException('"destination"-account is null, so we cannot continue!');
|
||||
}
|
||||
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
@@ -93,7 +90,7 @@ trait SupportJournalsTrait
|
||||
*/
|
||||
protected function storeBudgetWithJournal(TransactionJournal $journal, int $budgetId)
|
||||
{
|
||||
if (intval($budgetId) > 0 && $journal->transactionType->type === TransactionType::WITHDRAWAL) {
|
||||
if (intval($budgetId) > 0 && TransactionType::WITHDRAWAL === $journal->transactionType->type) {
|
||||
/** @var \FireflyIII\Models\Budget $budget */
|
||||
$budget = Budget::find($budgetId);
|
||||
$journal->budgets()->save($budget);
|
||||
@@ -215,6 +212,7 @@ trait SupportJournalsTrait
|
||||
* @param array $accounts
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function verifyNativeAmount(array $data, array $accounts): array
|
||||
@@ -227,7 +225,7 @@ trait SupportJournalsTrait
|
||||
|
||||
// which account to check for what the native currency is?
|
||||
$check = 'source';
|
||||
if ($transactionType->type === TransactionType::DEPOSIT) {
|
||||
if (TransactionType::DEPOSIT === $transactionType->type) {
|
||||
$check = 'destination';
|
||||
}
|
||||
switch ($transactionType->type) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
@@ -34,15 +33,12 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Trait UpdateJournalsTrait
|
||||
*
|
||||
* @package FireflyIII\Repositories\Journal
|
||||
* Trait UpdateJournalsTrait.
|
||||
*/
|
||||
trait UpdateJournalsTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* When the user edits a split journal, each line is missing crucial data:
|
||||
* When the user edits a split journal, each line is missing crucial data:.
|
||||
*
|
||||
* - Withdrawal lines are missing the source account ID
|
||||
* - Deposit lines are missing the destination account ID
|
||||
@@ -84,14 +80,14 @@ trait UpdateJournalsTrait
|
||||
protected function updateDestinationTransaction(TransactionJournal $journal, Account $account, array $data)
|
||||
{
|
||||
$set = $journal->transactions()->where('amount', '>', 0)->get();
|
||||
if ($set->count() !== 1) {
|
||||
if (1 !== $set->count()) {
|
||||
throw new FireflyException(sprintf('Journal #%d has %d transactions with an amount more than zero.', $journal->id, $set->count()));
|
||||
}
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $set->first();
|
||||
$transaction->amount = app('steam')->positive($data['amount']);
|
||||
$transaction->transaction_currency_id = $data['currency_id'];
|
||||
$transaction->foreign_amount = is_null($data['foreign_amount']) ? null : app('steam')->positive($data['foreign_amount']);
|
||||
$transaction->foreign_amount = null === $data['foreign_amount'] ? null : app('steam')->positive($data['foreign_amount']);
|
||||
$transaction->foreign_currency_id = $data['foreign_currency_id'];
|
||||
$transaction->account_id = $account->id;
|
||||
$transaction->save();
|
||||
@@ -108,14 +104,14 @@ trait UpdateJournalsTrait
|
||||
{
|
||||
// should be one:
|
||||
$set = $journal->transactions()->where('amount', '<', 0)->get();
|
||||
if ($set->count() !== 1) {
|
||||
if (1 !== $set->count()) {
|
||||
throw new FireflyException(sprintf('Journal #%d has %d transactions with an amount more than zero.', $journal->id, $set->count()));
|
||||
}
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $set->first();
|
||||
$transaction->amount = bcmul(app('steam')->positive($data['amount']), '-1');
|
||||
$transaction->transaction_currency_id = $data['currency_id'];
|
||||
$transaction->foreign_amount = is_null($data['foreign_amount']) ? null : bcmul(app('steam')->positive($data['foreign_amount']), '-1');
|
||||
$transaction->foreign_amount = null === $data['foreign_amount'] ? null : bcmul(app('steam')->positive($data['foreign_amount']), '-1');
|
||||
$transaction->foreign_currency_id = $data['foreign_currency_id'];
|
||||
$transaction->account_id = $account->id;
|
||||
$transaction->save();
|
||||
@@ -133,7 +129,6 @@ trait UpdateJournalsTrait
|
||||
/** @var TagRepositoryInterface $tagRepository */
|
||||
$tagRepository = app(TagRepositoryInterface::class);
|
||||
|
||||
|
||||
// find or create all tags:
|
||||
$tags = [];
|
||||
$ids = [];
|
||||
@@ -150,7 +145,7 @@ trait UpdateJournalsTrait
|
||||
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->whereNotIn('tag_id', $ids)->delete();
|
||||
}
|
||||
// if count is zero, delete them all:
|
||||
if (count($ids) === 0) {
|
||||
if (0 === count($ids)) {
|
||||
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->delete();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user