Improve code quality and add documentation in folder "Generator"

This commit is contained in:
James Cole 2018-07-07 07:18:49 +02:00
parent 8692590600
commit a1056147d8
23 changed files with 249 additions and 51 deletions

View File

@ -31,17 +31,20 @@ use Illuminate\Support\Collection;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts involved in the report. */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon The end date */
private $end; private $end;
/** @var Collection */ /** @var Collection The expense accounts. */
private $expense; private $expense;
/** @var Carbon */ /** @var Carbon The start date. */
private $start; private $start;
/** /**
* Generate the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -57,6 +60,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -69,6 +74,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set budgets.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -79,6 +86,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set categories.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -89,6 +98,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set end date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -101,6 +112,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set expense collection.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -113,6 +126,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set start date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -125,6 +140,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set collection of tags.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -135,6 +152,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Return the preferred period.
*
* @return string * @return string
*/ */
protected function preferredPeriod(): string protected function preferredPeriod(): string

View File

@ -27,9 +27,9 @@ namespace FireflyIII\Generator\Report\Account;
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/** /**
* Returns the preferred period.
*
* @return string * @return string
*/ */
protected function preferredPeriod(): string protected function preferredPeriod(): string

View File

@ -27,9 +27,9 @@ namespace FireflyIII\Generator\Report\Account;
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/** /**
* Returns the preferred period.
*
* @return string * @return string
*/ */
protected function preferredPeriod(): string protected function preferredPeriod(): string

View File

@ -18,15 +18,20 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Audit; namespace FireflyIII\Generator\Report\Audit;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Steam; use Steam;
@ -36,15 +41,18 @@ use Steam;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts used. */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon End date of the report. */
private $end; private $end;
/** @var Carbon */ /** @var Carbon Start date of the report. */
private $start; private $start;
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -77,6 +85,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Account collection setter.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -89,6 +99,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Budget collection setter.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -99,6 +111,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Category collection setter.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -109,6 +123,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* End date setter.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -121,6 +137,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Expenses collection setter.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -131,6 +149,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Start date collection setter.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -143,6 +163,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Tags collection setter.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -153,18 +175,25 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Get the audit report.
*
* @param Account $account * @param Account $account
* @param Carbon $date * @param Carbon $date
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
* @throws FireflyException
*/ */
private function getAuditReport(Account $account, Carbon $date): array private function getAuditReport(Account $account, Carbon $date): array
{ {
/** @var CurrencyRepositoryInterface $currencyRepos */ /** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class); $currencyRepos = app(CurrencyRepositoryInterface::class);
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$accountRepository->setUser($account->user);
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end); $collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
@ -172,7 +201,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
$journals = $journals->reverse(); $journals = $journals->reverse();
$dayBeforeBalance = Steam::balance($account, $date); $dayBeforeBalance = Steam::balance($account, $date);
$startBalance = $dayBeforeBalance; $startBalance = $dayBeforeBalance;
$currency = $currencyRepos->find((int)$account->getMeta('currency_id')); $currency = $currencyRepos->findNull((int)$accountRepository->getMetaValue($account, 'currency_id'));
if (null === $currency) {
throw new FireflyException('Unexpected NULL value in account currency preference.');
}
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journals as $transaction) { foreach ($journals as $transaction) {
@ -186,7 +219,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
$newBalance = bcadd($startBalance, $transactionAmount); $newBalance = bcadd($startBalance, $transactionAmount);
$transaction->after = $newBalance; $transaction->after = $newBalance;
$startBalance = $newBalance; $startBalance = $newBalance;
$transaction->currency = $currency;
} }
$return = [ $return = [

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Audit;
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Audit;
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -18,6 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection MultipleReturnStatementsInspection */
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Budget; namespace FireflyIII\Generator\Report\Budget;
@ -39,17 +41,15 @@ use Log;
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts in the report. */
private $accounts; private $accounts;
/** @var Collection */ /** @var Collection The budgets in the report. */
private $budgets; private $budgets;
/** @var Carbon */ /** @var Carbon The end date. */
private $end; private $end;
/** @var Collection */ /** @var Collection The expenses in the report. */
private $expenses; private $expenses;
/** @var Collection */ /** @var Carbon The start date. */
private $income;
/** @var Carbon */
private $start; private $start;
/** /**
@ -57,12 +57,14 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
*/ */
public function __construct() public function __construct()
{ {
$this->income = new Collection;
$this->expenses = new Collection; $this->expenses = new Collection;
} }
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -83,6 +85,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the involved accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -95,6 +99,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the involved budgets.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -107,6 +113,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused category setter.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -117,6 +125,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the end date of the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -129,6 +139,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused expense setter.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -139,6 +151,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the start date of the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -151,6 +165,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused tags setter.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -161,6 +177,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Get the expenses.
*
* @return Collection * @return Collection
*/ */
protected function getExpenses(): Collection protected function getExpenses(): Collection
@ -188,6 +206,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Summarize a collection by its budget.
*
* @param Collection $collection * @param Collection $collection
* *
* @return array * @return array

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Budget;
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Budget;
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -18,6 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection MultipleReturnStatementsInspection */
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Category; namespace FireflyIII\Generator\Report\Category;
@ -40,17 +42,17 @@ use Log;
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The included accounts */
private $accounts; private $accounts;
/** @var Collection */ /** @var Collection The included categories */
private $categories; private $categories;
/** @var Carbon */ /** @var Carbon The end date */
private $end; private $end;
/** @var Collection */ /** @var Collection The expenses */
private $expenses; private $expenses;
/** @var Collection */ /** @var Collection The income in the report. */
private $income; private $income;
/** @var Carbon */ /** @var Carbon The start date. */
private $start; private $start;
/** /**
@ -63,7 +65,10 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -101,6 +106,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the involved accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -113,6 +120,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Empty budget setter.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -123,6 +132,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the categories involved in this report.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -135,6 +146,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the end date for this report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -147,6 +160,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the expenses involved in this report.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -157,6 +172,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the start date for this report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -169,6 +186,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused tag setter.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -179,6 +198,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Get the expenses for this report.
*
* @return Collection * @return Collection
*/ */
protected function getExpenses(): Collection protected function getExpenses(): Collection
@ -206,6 +227,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Get the income for this report.
*
* @return Collection * @return Collection
*/ */
protected function getIncome(): Collection protected function getIncome(): Collection
@ -230,6 +253,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Summarize the category.
*
* @param Collection $collection * @param Collection $collection
* *
* @return array * @return array

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Category;
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Category;
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -31,6 +31,8 @@ use FireflyIII\Exceptions\FireflyException;
class ReportGeneratorFactory class ReportGeneratorFactory
{ {
/** /**
* Static report generator class.
*
* @param string $type * @param string $type
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end

View File

@ -31,11 +31,15 @@ use Illuminate\Support\Collection;
interface ReportGeneratorInterface interface ReportGeneratorInterface
{ {
/** /**
* Generate the report.
*
* @return string * @return string
*/ */
public function generate(): string; public function generate(): string;
/** /**
* Set the involved accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -43,6 +47,8 @@ interface ReportGeneratorInterface
public function setAccounts(Collection $accounts): ReportGeneratorInterface; public function setAccounts(Collection $accounts): ReportGeneratorInterface;
/** /**
* Set the involved budgets.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -50,6 +56,8 @@ interface ReportGeneratorInterface
public function setBudgets(Collection $budgets): ReportGeneratorInterface; public function setBudgets(Collection $budgets): ReportGeneratorInterface;
/** /**
* Set the involved categories.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -57,6 +65,8 @@ interface ReportGeneratorInterface
public function setCategories(Collection $categories): ReportGeneratorInterface; public function setCategories(Collection $categories): ReportGeneratorInterface;
/** /**
* Set the end date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -64,6 +74,8 @@ interface ReportGeneratorInterface
public function setEndDate(Carbon $date): ReportGeneratorInterface; public function setEndDate(Carbon $date): ReportGeneratorInterface;
/** /**
* Set the expense accounts.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -71,6 +83,8 @@ interface ReportGeneratorInterface
public function setExpense(Collection $expense): ReportGeneratorInterface; public function setExpense(Collection $expense): ReportGeneratorInterface;
/** /**
* Set the start date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -78,6 +92,8 @@ interface ReportGeneratorInterface
public function setStartDate(Carbon $date): ReportGeneratorInterface; public function setStartDate(Carbon $date): ReportGeneratorInterface;
/** /**
* Set the tags.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface

View File

@ -32,15 +32,18 @@ use Illuminate\Support\Collection;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts involved in the report. */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon The end date. */
private $end; private $end;
/** @var Carbon */ /** @var Carbon The start date. */
private $start; private $start;
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -58,6 +61,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Sets the accounts involved in the report.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -70,6 +75,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused budget setter.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -80,6 +87,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused category setter.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -90,6 +99,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the end date of the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -102,6 +113,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the expenses used in this report.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -112,6 +125,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the start date of this report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -124,6 +139,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the tags used in this report.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface

View File

@ -31,15 +31,18 @@ use Illuminate\Support\Collection;
*/ */
class MultiYearReportGenerator implements ReportGeneratorInterface class MultiYearReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts involved. */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon The end date. */
private $end; private $end;
/** @var Carbon */ /** @var Carbon The start date. */
private $start; private $start;
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -55,6 +58,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Sets the accounts used in the report.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -67,6 +72,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Sets the budgets used in the report.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -77,6 +84,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Sets the categories used in the report.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -87,6 +96,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Sets the end date used in the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -99,6 +110,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused setter for expenses.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -109,6 +122,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the start date of the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -121,6 +136,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the tags for the report.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface

View File

@ -31,15 +31,18 @@ use Illuminate\Support\Collection;
*/ */
class YearReportGenerator implements ReportGeneratorInterface class YearReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts involved. */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon The end date. */
private $end; private $end;
/** @var Carbon */ /** @var Carbon The start date. */
private $start; private $start;
/** /**
* Generates the report.
*
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -55,6 +58,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -67,6 +72,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused budget setter.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -77,6 +84,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused categories setter.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -87,6 +96,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the end date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -99,6 +110,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the expenses used.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -109,6 +122,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Set the start date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -121,6 +136,8 @@ class YearReportGenerator implements ReportGeneratorInterface
} }
/** /**
* Unused tags setter.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface

View File

@ -18,6 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report; namespace FireflyIII\Generator\Report;
@ -31,6 +33,8 @@ use Illuminate\Support\Collection;
class Support class Support
{ {
/** /**
* Get the top expenses.
*
* @return Collection * @return Collection
*/ */
public function getTopExpenses(): Collection public function getTopExpenses(): Collection
@ -39,6 +43,8 @@ class Support
} }
/** /**
* Get the top income.
*
* @return Collection * @return Collection
*/ */
public function getTopIncome(): Collection public function getTopIncome(): Collection
@ -47,6 +53,8 @@ class Support
} }
/** /**
* Get averages from a collection.
*
* @param Collection $collection * @param Collection $collection
* @param int $sortFlag * @param int $sortFlag
* *
@ -89,6 +97,8 @@ class Support
} }
/** /**
* Summarize collection by earned and spent data.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
* *
* @param array $spent * @param array $spent
@ -117,7 +127,6 @@ class Support
$return[$objectId]['spent'] = $entry; $return[$objectId]['spent'] = $entry;
$return['sum']['spent'] = bcadd($return['sum']['spent'], $entry); $return['sum']['spent'] = bcadd($return['sum']['spent'], $entry);
} }
unset($entry);
/** /**
* @var int * @var int
@ -136,6 +145,8 @@ class Support
} }
/** /**
* Summarize the data by account.
*
* @param Collection $collection * @param Collection $collection
* *
* @return array * @return array

View File

@ -18,6 +18,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection MultipleReturnStatementsInspection */
/** @noinspection PhpUndefinedMethodInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Tag; namespace FireflyIII\Generator\Report\Tag;
@ -41,17 +44,17 @@ use Log;
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection The accounts involved */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon The end date */
private $end; private $end;
/** @var Collection */ /** @var Collection The expenses involved */
private $expenses; private $expenses;
/** @var Collection */ /** @var Collection The income involved */
private $income; private $income;
/** @var Carbon */ /** @var Carbon The start date */
private $start; private $start;
/** @var Collection */ /** @var Collection The tags involved. */
private $tags; private $tags;
/** /**
@ -64,7 +67,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Generate the report.
*
* @return string * @return string
* @throws \Throwable
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -98,6 +105,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the accounts.
*
* @param Collection $accounts * @param Collection $accounts
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -110,6 +119,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused budget setter.
*
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -120,6 +131,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Unused category setter.
*
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -130,6 +143,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the end date of the report.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -142,6 +157,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the expenses in this report.
*
* @param Collection $expense * @param Collection $expense
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -152,6 +169,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the start date.
*
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -164,6 +183,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Set the tags used in this report.
*
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
@ -176,6 +197,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Get expense collection for report.
*
* @return Collection * @return Collection
*/ */
protected function getExpenses(): Collection protected function getExpenses(): Collection
@ -204,6 +227,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Get the income for this report.
*
* @return Collection * @return Collection
*/ */
protected function getIncome(): Collection protected function getIncome(): Collection
@ -228,6 +253,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** /**
* Summarize by tag.
*
* @param Collection $collection * @param Collection $collection
* *
* @return array * @return array

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Tag;
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Tag;
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
} }

View File

@ -83,6 +83,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property TransactionCurrency $transactionCurrency * @property TransactionCurrency $transactionCurrency
* @property int $transaction_journal_id * @property int $transaction_journal_id
* @property TransactionCurrency $foreignCurrency * @property TransactionCurrency $foreignCurrency
* @property string $before // used in audit reports.
* @property string $after // used in audit reports.
*/ */
class Transaction extends Model class Transaction extends Model
{ {

View File

@ -48,6 +48,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $transaction_type_id * @property int $transaction_type_id
* @property int transaction_currency_id * @property int transaction_currency_id
* @property TransactionCurrency $transactionCurrency * @property TransactionCurrency $transactionCurrency
* @property Collection $tags
*/ */
class TransactionJournal extends Model class TransactionJournal extends Model
{ {