mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Clean up code.
This commit is contained in:
@@ -40,9 +40,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
*/
|
||||
class AccountTransformer extends AbstractTransformer
|
||||
{
|
||||
protected AccountRepositoryInterface $repository;
|
||||
protected bool $convertToNative;
|
||||
protected TransactionCurrency $native;
|
||||
protected AccountRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* AccountTransformer constructor.
|
||||
|
||||
@@ -50,21 +50,21 @@ class AttachmentTransformer extends AbstractTransformer
|
||||
$this->repository->setUser($attachment->user);
|
||||
|
||||
return [
|
||||
'id' => (string) $attachment->id,
|
||||
'created_at' => $attachment->created_at->toAtomString(),
|
||||
'updated_at' => $attachment->updated_at->toAtomString(),
|
||||
'attachable_id' => (string) $attachment->attachable_id,
|
||||
'attachable_type' => str_replace('FireflyIII\Models\\', '', $attachment->attachable_type),
|
||||
'md5' => $attachment->md5,
|
||||
'hash' => $attachment->md5,
|
||||
'filename' => $attachment->filename,
|
||||
'download_url' => route('api.v1.attachments.download', [$attachment->id]),
|
||||
'upload_url' => route('api.v1.attachments.upload', [$attachment->id]),
|
||||
'title' => $attachment->title,
|
||||
'notes' => $this->repository->getNoteText($attachment),
|
||||
'mime' => $attachment->mime,
|
||||
'size' => (int) $attachment->size,
|
||||
'links' => [
|
||||
'id' => (string) $attachment->id,
|
||||
'created_at' => $attachment->created_at->toAtomString(),
|
||||
'updated_at' => $attachment->updated_at->toAtomString(),
|
||||
'attachable_id' => (string) $attachment->attachable_id,
|
||||
'attachable_type' => str_replace('FireflyIII\Models\\', '', $attachment->attachable_type),
|
||||
'md5' => $attachment->md5,
|
||||
'hash' => $attachment->md5,
|
||||
'filename' => $attachment->filename,
|
||||
'download_url' => route('api.v1.attachments.download', [$attachment->id]),
|
||||
'upload_url' => route('api.v1.attachments.upload', [$attachment->id]),
|
||||
'title' => $attachment->title,
|
||||
'notes' => $this->repository->getNoteText($attachment),
|
||||
'mime' => $attachment->mime,
|
||||
'size' => (int) $attachment->size,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/attachment/'.$attachment->id,
|
||||
|
||||
@@ -36,11 +36,11 @@ use FireflyIII\Support\Facades\Amount;
|
||||
*/
|
||||
class AvailableBudgetTransformer extends AbstractTransformer
|
||||
{
|
||||
private readonly bool $convertToNative;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly NoBudgetRepositoryInterface $noBudgetRepository;
|
||||
private readonly OperationsRepositoryInterface $opsRepository;
|
||||
private readonly BudgetRepositoryInterface $repository;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly bool $convertToNative;
|
||||
|
||||
/**
|
||||
* CurrencyTransformer constructor.
|
||||
|
||||
@@ -41,9 +41,9 @@ use Illuminate\Support\Collection;
|
||||
class BillTransformer extends AbstractTransformer
|
||||
{
|
||||
private readonly BillDateCalculator $calculator;
|
||||
private readonly BillRepositoryInterface $repository;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly bool $convertToNative;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly BillRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* BillTransformer constructor.
|
||||
|
||||
@@ -41,9 +41,8 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
= [
|
||||
'budget',
|
||||
];
|
||||
|
||||
protected TransactionCurrency $default;
|
||||
protected bool $convertToNative;
|
||||
protected TransactionCurrency $default;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -38,10 +38,10 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
*/
|
||||
class BudgetTransformer extends AbstractTransformer
|
||||
{
|
||||
private readonly OperationsRepositoryInterface $opsRepository;
|
||||
private readonly BudgetRepositoryInterface $repository;
|
||||
private readonly bool $convertToNative;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly OperationsRepositoryInterface $opsRepository;
|
||||
private readonly BudgetRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* BudgetTransformer constructor.
|
||||
|
||||
@@ -36,10 +36,10 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class CategoryTransformer extends AbstractTransformer
|
||||
{
|
||||
private readonly bool $convertToNative;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly OperationsRepositoryInterface $opsRepository;
|
||||
private readonly CategoryRepositoryInterface $repository;
|
||||
private readonly TransactionCurrency $default;
|
||||
private readonly bool $convertToNative;
|
||||
|
||||
/**
|
||||
* CategoryTransformer constructor.
|
||||
|
||||
@@ -83,14 +83,14 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$first = new NullArrayObject(reset($group['transactions']));
|
||||
|
||||
return [
|
||||
'id' => (int) $first['transaction_group_id'],
|
||||
'created_at' => $first['created_at']->toAtomString(),
|
||||
'updated_at' => $first['updated_at']->toAtomString(),
|
||||
'user' => (string) $data['user_id'],
|
||||
'user_group' => (string) $data['user_group_id'],
|
||||
'group_title' => $data['title'],
|
||||
'transactions' => $this->transformTransactions($data),
|
||||
'links' => [
|
||||
'id' => (int) $first['transaction_group_id'],
|
||||
'created_at' => $first['created_at']->toAtomString(),
|
||||
'updated_at' => $first['updated_at']->toAtomString(),
|
||||
'user' => (string) $data['user_id'],
|
||||
'user_group' => (string) $data['user_group_id'],
|
||||
'group_title' => $data['title'],
|
||||
'transactions' => $this->transformTransactions($data),
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/transactions/'.$first['transaction_group_id'],
|
||||
@@ -231,12 +231,6 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getLocation(TransactionJournal $journal): ?Location
|
||||
{
|
||||
/** @var null|Location */
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -526,4 +520,10 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function getLocation(TransactionJournal $journal): ?Location
|
||||
{
|
||||
/** @var null|Location */
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ class AccountTransformer extends AbstractTransformer
|
||||
private array $accountMeta;
|
||||
private array $accountTypes;
|
||||
private array $balanceDifferences;
|
||||
private array $balances;
|
||||
private array $convertedBalances;
|
||||
private array $currencies;
|
||||
private TransactionCurrency $default;
|
||||
private array $fullTypes;
|
||||
private array $lastActivity;
|
||||
private array $objectGroups;
|
||||
private array $balances;
|
||||
|
||||
/**
|
||||
* This method collects meta-data for one or all accounts in the transformer's collection.
|
||||
|
||||
@@ -143,9 +143,9 @@ class BillTransformer extends AbstractTransformer
|
||||
app('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id']));
|
||||
$foreignCurrencyId = (int) $transaction['foreign_currency_id'];
|
||||
$currencies[$foreignCurrencyId] ??= TransactionCurrency::find($foreignCurrencyId);
|
||||
$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencyName = $currencies[$foreignCurrencyId]->name; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencyName = $currencies[$foreignCurrencyId]->name; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol; // @phpstan-ignore property.notFound
|
||||
$foreignCurrencyDp = $currencies[$foreignCurrencyId]->decimal_places; // @phpstan-ignore property.notFound
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
private array $currencies = [];
|
||||
private TransactionCurrency $default; // collection of all currencies for this transformer.
|
||||
private array $journals = [];
|
||||
private array $objects = [];
|
||||
private array $meta = [];
|
||||
|
||||
// private array $currencies = [];
|
||||
// private array $transactionTypes = [];
|
||||
private array $meta = [];
|
||||
private array $notes = [];
|
||||
private array $notes = [];
|
||||
private array $objects = [];
|
||||
// private array $locations = [];
|
||||
private array $tags = [];
|
||||
private array $tags = [];
|
||||
// private array $amounts = [];
|
||||
// private array $foreignAmounts = [];
|
||||
// private array $journalCurrencies = [];
|
||||
|
||||
Reference in New Issue
Block a user