Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -27,12 +27,9 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
*
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
@@ -44,7 +41,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generate the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -53,37 +49,26 @@ class MonthReportGenerator implements ReportGeneratorInterface
$doubleIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account';
$preferredPeriod = $this->preferredPeriod();
try {
$result = view('reports.double.report', compact('accountIds', 'reportType', 'doubleIds', 'preferredPeriod'))
->with('start', $this->start)->with('end', $this->end)
->with('doubles', $this->expense)
->render();
} catch (Throwable $e) {
->render()
;
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;
}
/**
* Return the preferred period.
*
* @return string
*/
protected function preferredPeriod(): string
{
return 'day';
}
/**
* Set accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -94,10 +79,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set budgets.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -106,10 +87,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set categories.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -118,10 +95,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set end date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -132,10 +105,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set expense collection.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -146,10 +115,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set start date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -160,13 +125,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set collection of tags.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{
return $this;
}
/**
* Return the preferred period.
*/
protected function preferredPeriod(): string
{
return 'day';
}
}

View File

@@ -25,15 +25,11 @@ namespace FireflyIII\Generator\Report\Account;
/**
* Class MultiYearReportGenerator.
*
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
/**
* Returns the preferred period.
*
* @return string
*/
protected function preferredPeriod(): string
{

View File

@@ -25,15 +25,11 @@ namespace FireflyIII\Generator\Report\Account;
/**
* Class YearReportGenerator.
*
*/
class YearReportGenerator extends MonthReportGenerator
{
/**
* Returns the preferred period.
*
* @return string
*/
protected function preferredPeriod(): string
{

View File

@@ -31,8 +31,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use JsonException;
use Throwable;
/**
* Class MonthReportGenerator.
@@ -46,15 +44,15 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generates the report.
*
* @return string
* @throws FireflyException
* @throws JsonException
* @throws \JsonException
*/
public function generate(): string
{
$auditData = [];
$dayBefore = clone $this->start;
$dayBefore->subDay();
/** @var Account $account */
foreach ($this->accounts as $account) {
// balance the day before:
@@ -92,14 +90,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
'payment_date',
'invoice_date',
];
try {
$result = view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render();
} catch (Throwable $e) {
->render()
;
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
@@ -109,12 +110,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Get the audit report.
*
* @param Account $account
* @param Carbon $date
*
* @return array
* @throws FireflyException
* @throws JsonException
* @throws \JsonException
*/
public function getAuditReport(Account $account, Carbon $date): array
{
@@ -129,7 +126,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation()
->withBudgetInformation()->withCategoryInformation()->withBillInformation();
->withBudgetInformation()->withCategoryInformation()->withBillInformation()
;
$journals = $collector->getExtractedJournals();
$journals = array_reverse($journals, true);
$dayBeforeBalance = app('steam')->balance($account, $date);
@@ -180,10 +178,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Account collection setter.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -194,10 +188,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Budget collection setter.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -206,10 +196,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Category collection setter.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -218,10 +204,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* End date setter.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -232,10 +214,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Expenses collection setter.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -245,10 +223,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Start date collection setter.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -259,10 +233,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Tags collection setter.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Audit;
/**
* Class MultiYearReportGenerator.
*
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
}
class MultiYearReportGenerator extends MonthReportGenerator {}

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Audit;
/**
* Class YearReportGenerator.
*
*/
class YearReportGenerator extends MonthReportGenerator
{
}
class YearReportGenerator extends MonthReportGenerator {}

View File

@@ -29,13 +29,10 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
* TODO include info about tags.
*
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
@@ -56,13 +53,13 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generates the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
{
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$budgetIds = implode(',', $this->budgets->pluck('id')->toArray());
try {
$result = view(
'reports.budget.month',
@@ -71,11 +68,13 @@ class MonthReportGenerator implements ReportGeneratorInterface
->with('start', $this->start)->with('end', $this->end)
->with('budgets', $this->budgets)
->with('accounts', $this->accounts)
->render();
} catch (Throwable $e) {
->render()
;
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
@@ -84,10 +83,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused category setter.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -96,10 +91,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -110,10 +101,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused expense setter.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -122,10 +109,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -136,20 +119,34 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused tags setter.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{
return $this;
}
/**
* Set the involved budgets.
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
$this->budgets = $budgets;
return $this;
}
/**
* Set the involved accounts.
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Get the expenses.
*
* @return array
*/
protected function getExpenses(): array
{
@@ -162,42 +159,15 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL])
->withAccountInformation()
->withBudgetInformation()
->setBudgets($this->budgets);
->setTypes([TransactionType::WITHDRAWAL])
->withAccountInformation()
->withBudgetInformation()
->setBudgets($this->budgets)
;
$journals = $collector->getExtractedJournals();
$this->expenses = $journals;
return $journals;
}
/**
* Set the involved budgets.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
$this->budgets = $budgets;
return $this;
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
}

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Budget;
/**
* Class MultiYearReportGenerator.
*
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
}
class MultiYearReportGenerator extends MonthReportGenerator {}

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Budget;
/**
* Class YearReportGenerator.
*
*/
class YearReportGenerator extends MonthReportGenerator
{
}
class YearReportGenerator extends MonthReportGenerator {}

View File

@@ -29,13 +29,10 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
* TODO include info about tags
*
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
@@ -58,7 +55,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generates the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -73,21 +69,19 @@ class MonthReportGenerator implements ReportGeneratorInterface
->with('start', $this->start)->with('end', $this->end)
->with('categories', $this->categories)
->with('accounts', $this->accounts)
->render();
} catch (Throwable $e) {
->render()
;
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
}
/**
* Empty budget setter.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -96,10 +90,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date for this report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -110,10 +100,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses involved in this report.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -122,10 +108,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date for this report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -136,20 +118,34 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused tag setter.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{
return $this;
}
/**
* Set the categories involved in this report.
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
$this->categories = $categories;
return $this;
}
/**
* Set the involved accounts.
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Get the expenses for this report.
*
* @return array
*/
protected function getExpenses(): array
{
@@ -162,8 +158,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setCategories($this->categories)->withAccountInformation();
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setCategories($this->categories)->withAccountInformation()
;
$transactions = $collector->getExtractedJournals();
$this->expenses = $transactions;
@@ -171,38 +168,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $transactions;
}
/**
* Set the categories involved in this report.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
$this->categories = $categories;
return $this;
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Get the income for this report.
*
* @return array
*/
protected function getIncome(): array
{
@@ -214,8 +181,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
->setCategories($this->categories)->withAccountInformation();
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
->setCategories($this->categories)->withAccountInformation()
;
$transactions = $collector->getExtractedJournals();
$this->income = $transactions;

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Category;
/**
* Class MultiYearReportGenerator.
*
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
}
class MultiYearReportGenerator extends MonthReportGenerator {}

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Category;
/**
* Class YearReportGenerator.
*
*/
class YearReportGenerator extends MonthReportGenerator
{
}
class YearReportGenerator extends MonthReportGenerator {}

View File

@@ -28,20 +28,12 @@ use FireflyIII\Exceptions\FireflyException;
/**
* Class ReportGeneratorFactory.
*
*/
class ReportGeneratorFactory
{
/**
* Static report generator class.
*
* @param string $type
* @param Carbon $start
* @param Carbon $end
*
* @return ReportGeneratorInterface
*
* @throws FireflyException
*/
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
@@ -66,6 +58,7 @@ class ReportGeneratorFactory
return $obj;
}
throw new FireflyException(sprintf('Cannot generate report. There is no "%s"-report for period "%s".', $type, $period));
}
}

View File

@@ -33,71 +33,41 @@ interface ReportGeneratorInterface
{
/**
* Generate the report.
*
* @return string
*/
public function generate(): string;
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): self;
/**
* Set the involved budgets.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): self;
/**
* Set the involved categories.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): self;
/**
* Set the end date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): self;
/**
* Set the expense accounts.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): self;
/**
* Set the start date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): self;
/**
* Set the tags.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): self;
}

View File

@@ -27,26 +27,24 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
*
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
/** @var Collection The accounts involved in the report. */
private $accounts;
/** @var Carbon The end date. */
private $end;
/** @var Carbon The start date. */
private $start;
/**
* Generates the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -56,20 +54,17 @@ class MonthReportGenerator implements ReportGeneratorInterface
try {
return view('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = 'Could not render report view.';
throw new FireflyException($result, 0, $e);
}
}
/**
* Sets the accounts involved in the report.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -80,10 +75,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -92,10 +83,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused category setter.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -104,10 +91,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -118,10 +101,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses used in this report.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -130,10 +109,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of this report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -144,10 +119,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the tags used in this report.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{

View File

@@ -27,26 +27,24 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
*
*/
class MultiYearReportGenerator implements ReportGeneratorInterface
{
/** @var Collection The accounts involved. */
private $accounts;
/** @var Carbon The end date. */
private $end;
/** @var Carbon The start date. */
private $start;
/**
* Generates the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -60,20 +58,17 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
'reports.default.multi-year',
compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
}
/**
* Sets the accounts used in the report.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -84,10 +79,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the budgets used in the report.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -96,10 +87,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the categories used in the report.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -108,10 +95,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the end date used in the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -122,10 +105,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Unused setter for expenses.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -134,10 +113,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -148,10 +123,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Set the tags for the report.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{

View File

@@ -27,26 +27,24 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
*
*/
class YearReportGenerator implements ReportGeneratorInterface
{
/** @var Collection The accounts involved. */
private $accounts;
/** @var Carbon The end date. */
private $end;
/** @var Carbon The start date. */
private $start;
/**
* Generates the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -60,10 +58,11 @@ class YearReportGenerator implements ReportGeneratorInterface
'reports.default.year',
compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) {
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = 'Could not render report view.';
throw new FireflyException($result, 0, $e);
}
@@ -72,10 +71,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -86,10 +81,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -98,10 +89,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused categories setter.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -110,10 +97,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the end date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -124,10 +107,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses used.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -136,10 +115,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the start date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -150,10 +125,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused tags setter.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{

View File

@@ -27,12 +27,9 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class MonthReportGenerator.
*
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
@@ -53,7 +50,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generate the report.
*
* @return string
* @throws FireflyException
*/
public function generate(): string
@@ -68,10 +64,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
'reports.tag.month',
compact('accountIds', 'reportType', 'tagIds')
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) {
} catch (\Throwable $e) {
app('log')->error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
@@ -80,10 +77,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
@@ -94,10 +87,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
@@ -106,10 +95,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused category setter.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
@@ -118,10 +103,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface
{
@@ -132,10 +113,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses in this report.
*
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
public function setExpense(Collection $expense): ReportGeneratorInterface
{
@@ -144,10 +121,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date.
*
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface
{
@@ -158,10 +131,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the tags used in this report.
*
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface
{

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Tag;
/**
* Class MultiYearReportGenerator.
*
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
}
class MultiYearReportGenerator extends MonthReportGenerator {}

View File

@@ -25,9 +25,5 @@ namespace FireflyIII\Generator\Report\Tag;
/**
* Class YearReportGenerator.
*
*/
class YearReportGenerator extends MonthReportGenerator
{
}
class YearReportGenerator extends MonthReportGenerator {}