mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve code quality and add documentation in folder "Generator"
This commit is contained in:
parent
8692590600
commit
a1056147d8
@ -31,17 +31,20 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts involved in the report. */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
/** @var Collection The expense accounts. */
|
||||
private $expense;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* Generate the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -57,6 +60,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -69,6 +74,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set budgets.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -79,6 +86,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set categories.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -89,6 +98,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set end date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -101,6 +112,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set expense collection.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -113,6 +126,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set start date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -125,6 +140,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set collection of tags.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -135,6 +152,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the preferred period.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function preferredPeriod(): string
|
||||
|
@ -27,9 +27,9 @@ namespace FireflyIII\Generator\Report\Account;
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
|
||||
/**
|
||||
* Returns the preferred period.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function preferredPeriod(): string
|
||||
|
@ -27,9 +27,9 @@ namespace FireflyIII\Generator\Report\Account;
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
|
||||
/**
|
||||
* Returns the preferred period.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function preferredPeriod(): string
|
||||
|
@ -18,15 +18,20 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Audit;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
@ -36,15 +41,18 @@ use Steam;
|
||||
*/
|
||||
class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts used. */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon End date of the report. */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon Start date of the report. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -77,6 +85,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Account collection setter.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -89,6 +99,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Budget collection setter.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -99,6 +111,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Category collection setter.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -109,6 +123,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* End date setter.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -121,6 +137,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Expenses collection setter.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -131,6 +149,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Start date collection setter.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -143,6 +163,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Tags collection setter.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -153,18 +175,25 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the audit report.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getAuditReport(Account $account, Carbon $date): array
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountRepository->setUser($account->user);
|
||||
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
|
||||
@ -172,7 +201,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$journals = $journals->reverse();
|
||||
$dayBeforeBalance = Steam::balance($account, $date);
|
||||
$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 */
|
||||
foreach ($journals as $transaction) {
|
||||
@ -186,7 +219,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$newBalance = bcadd($startBalance, $transactionAmount);
|
||||
$transaction->after = $newBalance;
|
||||
$startBalance = $newBalance;
|
||||
$transaction->currency = $currency;
|
||||
}
|
||||
|
||||
$return = [
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Audit;
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Audit;
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Budget;
|
||||
@ -39,17 +41,15 @@ use Log;
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts in the report. */
|
||||
private $accounts;
|
||||
/** @var Collection */
|
||||
/** @var Collection The budgets in the report. */
|
||||
private $budgets;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date. */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
/** @var Collection The expenses in the report. */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
@ -57,12 +57,14 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->income = new Collection;
|
||||
$this->expenses = new Collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -83,6 +85,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the involved accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -95,6 +99,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the involved budgets.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -107,6 +113,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused category setter.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -117,6 +125,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the end date of the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -129,6 +139,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused expense setter.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -139,6 +151,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date of the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -151,6 +165,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused tags setter.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -161,6 +177,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expenses.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getExpenses(): Collection
|
||||
@ -188,6 +206,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize a collection by its budget.
|
||||
*
|
||||
* @param Collection $collection
|
||||
*
|
||||
* @return array
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Budget;
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Budget;
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Category;
|
||||
@ -40,17 +42,17 @@ use Log;
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The included accounts */
|
||||
private $accounts;
|
||||
/** @var Collection */
|
||||
/** @var Collection The included categories */
|
||||
private $categories;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
/** @var Collection The expenses */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
/** @var Collection The income in the report. */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
@ -63,7 +65,10 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -101,6 +106,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the involved accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -113,6 +120,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty budget setter.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -123,6 +132,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the categories involved in this report.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -135,6 +146,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the end date for this report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -147,6 +160,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expenses involved in this report.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -157,6 +172,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date for this report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -169,6 +186,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused tag setter.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -179,6 +198,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expenses for this report.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getExpenses(): Collection
|
||||
@ -206,6 +227,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the income for this report.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getIncome(): Collection
|
||||
@ -230,6 +253,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize the category.
|
||||
*
|
||||
* @param Collection $collection
|
||||
*
|
||||
* @return array
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Category;
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Category;
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
class ReportGeneratorFactory
|
||||
{
|
||||
/**
|
||||
* Static report generator class.
|
||||
*
|
||||
* @param string $type
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -31,11 +31,15 @@ use Illuminate\Support\Collection;
|
||||
interface ReportGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* Generate the report.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate(): string;
|
||||
|
||||
/**
|
||||
* Set the involved accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -43,6 +47,8 @@ interface ReportGeneratorInterface
|
||||
public function setAccounts(Collection $accounts): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the involved budgets.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -50,6 +56,8 @@ interface ReportGeneratorInterface
|
||||
public function setBudgets(Collection $budgets): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the involved categories.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -57,6 +65,8 @@ interface ReportGeneratorInterface
|
||||
public function setCategories(Collection $categories): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the end date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -64,6 +74,8 @@ interface ReportGeneratorInterface
|
||||
public function setEndDate(Carbon $date): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the expense accounts.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -71,6 +83,8 @@ interface ReportGeneratorInterface
|
||||
public function setExpense(Collection $expense): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the start date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -78,6 +92,8 @@ interface ReportGeneratorInterface
|
||||
public function setStartDate(Carbon $date): ReportGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Set the tags.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
|
@ -32,15 +32,18 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts involved in the report. */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date. */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -58,6 +61,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the accounts involved in the report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -70,6 +75,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused budget setter.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -80,6 +87,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused category setter.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -90,6 +99,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the end date of the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -102,6 +113,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expenses used in this report.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -112,6 +125,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date of this report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -124,6 +139,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags used in this report.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
|
@ -31,15 +31,18 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts involved. */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date. */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -55,6 +58,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the accounts used in the report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -67,6 +72,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the budgets used in the report.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -77,6 +84,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the categories used in the report.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -87,6 +96,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the end date used in the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -99,6 +110,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused setter for expenses.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -109,6 +122,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date of the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -121,6 +136,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for the report.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
|
@ -31,15 +31,18 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class YearReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts involved. */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date. */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date. */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* Generates the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -55,6 +58,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -67,6 +72,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused budget setter.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -77,6 +84,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused categories setter.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -87,6 +96,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the end date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -99,6 +110,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expenses used.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -109,6 +122,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -121,6 +136,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused tags setter.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
|
@ -18,6 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report;
|
||||
@ -31,6 +33,8 @@ use Illuminate\Support\Collection;
|
||||
class Support
|
||||
{
|
||||
/**
|
||||
* Get the top expenses.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTopExpenses(): Collection
|
||||
@ -39,6 +43,8 @@ class Support
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top income.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTopIncome(): Collection
|
||||
@ -47,6 +53,8 @@ class Support
|
||||
}
|
||||
|
||||
/**
|
||||
* Get averages from a collection.
|
||||
*
|
||||
* @param Collection $collection
|
||||
* @param int $sortFlag
|
||||
*
|
||||
@ -89,6 +97,8 @@ class Support
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize collection by earned and spent data.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
||||
*
|
||||
* @param array $spent
|
||||
@ -117,7 +127,6 @@ class Support
|
||||
$return[$objectId]['spent'] = $entry;
|
||||
$return['sum']['spent'] = bcadd($return['sum']['spent'], $entry);
|
||||
}
|
||||
unset($entry);
|
||||
|
||||
/**
|
||||
* @var int
|
||||
@ -136,6 +145,8 @@ class Support
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize the data by account.
|
||||
*
|
||||
* @param Collection $collection
|
||||
*
|
||||
* @return array
|
||||
|
@ -18,6 +18,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Tag;
|
||||
@ -41,17 +44,17 @@ use Log;
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection The accounts involved */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The end date */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
/** @var Collection The expenses involved */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
/** @var Collection The income involved */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon The start date */
|
||||
private $start;
|
||||
/** @var Collection */
|
||||
/** @var Collection The tags involved. */
|
||||
private $tags;
|
||||
|
||||
/**
|
||||
@ -64,7 +67,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the report.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
@ -98,6 +105,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -110,6 +119,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused budget setter.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -120,6 +131,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused category setter.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -130,6 +143,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the end date of the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -142,6 +157,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expenses in this report.
|
||||
*
|
||||
* @param Collection $expense
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -152,6 +169,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -164,6 +183,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags used in this report.
|
||||
*
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
@ -176,6 +197,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get expense collection for report.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getExpenses(): Collection
|
||||
@ -204,6 +227,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the income for this report.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getIncome(): Collection
|
||||
@ -228,6 +253,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize by tag.
|
||||
*
|
||||
* @param Collection $collection
|
||||
*
|
||||
* @return array
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Tag;
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -27,5 +27,4 @@ namespace FireflyIII\Generator\Report\Tag;
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property int $transaction_journal_id
|
||||
* @property TransactionCurrency $foreignCurrency
|
||||
* @property string $before // used in audit reports.
|
||||
* @property string $after // used in audit reports.
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int $transaction_type_id
|
||||
* @property int transaction_currency_id
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property Collection $tags
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user