mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
First part of a large code cleanup commit.
This commit is contained in:
@@ -62,7 +62,7 @@ class AccountDestroyService
|
||||
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
||||
|
||||
// also update recurring transactions:
|
||||
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
|
||||
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
|
||||
DB::table('recurrences_transactions')->where('destination_id', $account->id)->update(['destination_id' => $moveTo->id]);
|
||||
}
|
||||
$service = app(JournalDestroyService::class);
|
||||
|
||||
@@ -64,7 +64,7 @@ class EncryptService
|
||||
throw new FireflyException($message);
|
||||
}
|
||||
$newName = sprintf('%s.upload', $key);
|
||||
$disk = Storage::disk('upload');
|
||||
$disk = Storage::disk('upload');
|
||||
$disk->put($newName, $content);
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ trait AccountServiceTrait
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($user);
|
||||
|
||||
|
||||
return $factory->findOrCreate($opposingAccountName, AccountType::INITIAL_BALANCE);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Support;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Trait BillServiceTrait
|
||||
@@ -70,7 +72,11 @@ trait BillServiceTrait
|
||||
if ('' === $note) {
|
||||
$dbNote = $bill->notes()->first();
|
||||
if (null !== $dbNote) {
|
||||
$dbNote->delete(); // @codeCoverageIgnore
|
||||
try {
|
||||
$dbNote->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Error deleting note: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -55,7 +55,7 @@ trait JournalServiceTrait
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
foreach ($data['tags'] as $string) {
|
||||
if (\strlen($string) > 0) {
|
||||
if ('' != $string) {
|
||||
$tag = $factory->findOrCreate($string);
|
||||
if (null !== $tag) {
|
||||
$set[] = $tag->id;
|
||||
@@ -116,7 +116,7 @@ trait JournalServiceTrait
|
||||
protected function storeNote(TransactionJournal $journal, ?string $notes): void
|
||||
{
|
||||
$notes = (string)$notes;
|
||||
if (\strlen($notes) > 0) {
|
||||
if ('' !== $notes) {
|
||||
$note = $journal->notes()->first();
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
|
||||
@@ -107,7 +107,7 @@ trait TransactionServiceTrait
|
||||
return $repository->findByName($accountName, [AccountType::ASSET]);
|
||||
}
|
||||
// for revenue and expense:
|
||||
if (\strlen($accountName) > 0) {
|
||||
if ('' !== $accountName) {
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
@@ -218,7 +218,7 @@ trait TransactionServiceTrait
|
||||
return;
|
||||
}
|
||||
// enable currency if not enabled:
|
||||
if(false === $currency->enabled) {
|
||||
if (false === $currency->enabled) {
|
||||
$currency->enabled = true;
|
||||
$currency->save();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Services\Internal\Support\BillServiceTrait;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class BillUpdateService
|
||||
@@ -59,7 +60,7 @@ class BillUpdateService
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
|
||||
|
||||
if(null === $currency) {
|
||||
if (null === $currency) {
|
||||
// use default currency:
|
||||
$currency = app('amount')->getDefaultCurrencyByUser($bill->user);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Services\Internal\Support\JournalServiceTrait;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class to centralise code that updates a journal given the input by system.
|
||||
*
|
||||
@@ -38,6 +39,7 @@ use Log;
|
||||
class JournalUpdateService
|
||||
{
|
||||
use JournalServiceTrait;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -159,6 +161,7 @@ class JournalUpdateService
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$service->updateBudget($transaction, $budgetId);
|
||||
}
|
||||
|
||||
return $journal;
|
||||
}
|
||||
// clear budget.
|
||||
|
||||
@@ -27,6 +27,7 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
|
||||
use FireflyIII\User;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionUpdateService
|
||||
*/
|
||||
@@ -34,6 +35,9 @@ class TransactionUpdateService
|
||||
{
|
||||
use TransactionServiceTrait;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -44,9 +48,6 @@ class TransactionUpdateService
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param int $transactionId
|
||||
*
|
||||
@@ -87,10 +88,10 @@ class TransactionUpdateService
|
||||
*/
|
||||
public function update(Transaction $transaction, array $data): Transaction
|
||||
{
|
||||
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
|
||||
$journal = $transaction->transactionJournal;
|
||||
$amount = (string)$data['amount'];
|
||||
$account = null;
|
||||
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
|
||||
$journal = $transaction->transactionJournal;
|
||||
$amount = (string)$data['amount'];
|
||||
$account = null;
|
||||
// update description:
|
||||
$transaction->description = $data['description'];
|
||||
$foreignAmount = null;
|
||||
|
||||
Reference in New Issue
Block a user