Remove unused code.

This commit is contained in:
James Cole 2019-08-16 21:23:20 +02:00
parent 5a2998c80e
commit 820358af73
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 0 additions and 545 deletions

View File

@ -1,128 +0,0 @@
<?php
/**
* Bill.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Helpers\Collection;
use Carbon\Carbon;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
/**
* Class Bill.
*
* @codeCoverageIgnore
*/
class Bill
{
/** @var Collection The bills. */
private $bills;
/** @var Carbon End date of the collection. */
private $endDate;
/** @var Carbon Start date of the collection. */
private $startDate;
/**
* Bill constructor.
*/
public function __construct()
{
$this->bills = new Collection;
}
/**
* Add a bill line.
*
* @param BillLine $bill
*/
public function addBill(BillLine $bill): void
{
$this->bills->push($bill);
}
/**
* Filter the bills (yes how very descriptive).
*/
public function filterBills(): void
{
Log::debug('Now in filterBills()');
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$start = $this->startDate;
$end = $this->endDate;
$lines = $this->bills->filter(
function (BillLine $line) use ($repository, $start, $end) {
// next expected match?
$date = $start;
Log::debug(sprintf('Now at bill line for bill "%s"', $line->getBill()->name));
Log::debug(sprintf('Default date to use is start date: %s', $date->format('Y-m-d')));
if ($line->isHit()) {
$date = $line->getLastHitDate();
Log::debug(sprintf('Line was hit, see date: %s. Always include it.', $date->format('Y-m-d')));
return $line;
}
$expected = $repository->nextExpectedMatch($line->getBill(), $date);
Log::debug(sprintf('Next expected match is %s', $expected->format('Y-m-d')));
if ($expected <= $end && $expected >= $start) {
Log::debug('This date is inside report limits');
return $line;
}
Log::debug('This date is OUTSIDE report limits');
return false;
}
);
$this->bills = $lines;
}
/**
* Bills getter.
*
* @return Collection
*/
public function getBills(): Collection
{
return $this->bills;
}
/**
* End date setter.
*
* @param Carbon $endDate
*/
public function setEndDate(Carbon $endDate): void
{
$this->endDate = $endDate;
}
/**
* Start date setter.
*
* @param Carbon $startDate
*/
public function setStartDate(Carbon $startDate): void
{
$this->startDate = $startDate;
}
}

View File

@ -1,270 +0,0 @@
<?php
/**
* BillLine.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Helpers\Collection;
use Carbon\Carbon;
use FireflyIII\Models\Bill as BillModel;
use FireflyIII\Models\TransactionCurrency;
/**
* Class BillLine.
*
* @codeCoverageIgnore
*/
class BillLine
{
/** @var string The amount */
protected $amount;
/** @var BillModel The bill. */
protected $bill;
/** @var bool Is it hit this period */
protected $hit;
/** @var string What was the max amount. */
protected $max;
/** @var string What was the min amount. */
protected $min;
/** @var TransactionCurrency The transaction currency */
private $currency;
/** @var Carbon Latest date that payment is expected. */
private $endOfPayDate;
/** @var Carbon Date of last hit */
private $lastHitDate;
/** @var Carbon Date of last payment */
private $payDate;
/** @var int Journal */
private $transactionJournalId;
/**
* BillLine constructor.
*/
public function __construct()
{
$this->lastHitDate = new Carbon;
}
/**
* Amount getter.
*
* @return string
*/
public function getAmount(): string
{
return $this->amount ?? '0';
}
/**
* Amount setter.
*
* @param string $amount
*/
public function setAmount(string $amount): void
{
$this->amount = $amount;
}
/**
* Bill getter.
*
* @return BillModel
*/
public function getBill(): BillModel
{
return $this->bill;
}
/**
* Bill setter.
*
* @param BillModel $bill
*/
public function setBill(BillModel $bill): void
{
$this->bill = $bill;
}
/**
* @return TransactionCurrency
*/
public function getCurrency(): TransactionCurrency
{
return $this->currency;
}
/**
* @param TransactionCurrency $currency
*/
public function setCurrency(TransactionCurrency $currency): void
{
$this->currency = $currency;
}
/**
* End of pay date getter.
*
* @return Carbon
*/
public function getEndOfPayDate(): Carbon
{
return $this->endOfPayDate;
}
/**
* End of pay date setter.
*
* @param Carbon $endOfPayDate
*/
public function setEndOfPayDate(Carbon $endOfPayDate): void
{
$this->endOfPayDate = $endOfPayDate;
}
/**
* Last hit date getter.
*
* @return Carbon
*/
public function getLastHitDate(): Carbon
{
return $this->lastHitDate;
}
/**
* Last hit date setter.
*
* @param Carbon $lastHitDate
*/
public function setLastHitDate(Carbon $lastHitDate): void
{
$this->lastHitDate = $lastHitDate;
}
/**
* Max getter.
*
* @return string
*/
public function getMax(): string
{
return $this->max;
}
/**
* Max setter.
*
* @param string $max
*/
public function setMax(string $max): void
{
$this->max = $max;
}
/**
* Min getter.
*
* @return string
*/
public function getMin(): string
{
return $this->min;
}
/**
* Min setter.
*
* @param string $min
*/
public function setMin(string $min): void
{
$this->min = $min;
}
/**
* Pay date getter.
*
* @return Carbon
*/
public function getPayDate(): Carbon
{
return $this->payDate;
}
/**
* Pay date setter.
*
* @param Carbon $payDate
*/
public function setPayDate(Carbon $payDate): void
{
$this->payDate = $payDate;
}
/**
* Journal ID getter.
*
* @return int
*/
public function getTransactionJournalId(): int
{
return $this->transactionJournalId ?? 0;
}
/**
* Journal ID setter.
*
* @param int $transactionJournalId
*/
public function setTransactionJournalId(int $transactionJournalId): void
{
$this->transactionJournalId = $transactionJournalId;
}
/**
* Is active.
*
* @return bool
*/
public function isActive(): bool
{
return 1 === (int)$this->bill->active;
}
/**
* Is hit.
*
* @return bool
*/
public function isHit(): bool
{
return $this->hit;
}
/**
* Set is hit.
*
* @param bool $hit
*/
public function setHit(bool $hit): void
{
$this->hit = $hit;
}
}

View File

@ -1,97 +0,0 @@
<?php
/**
* Category.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Category as CategoryModel;
use Illuminate\Support\Collection;
/**
* Class Category.
*
* @codeCoverageIgnore
*/
class Category
{
/** @var Collection The categories */
protected $categories;
/** @var string Total amount */
protected $total = '0';
/**
* Category constructor.
*/
public function __construct()
{
$this->categories = new Collection;
}
/**
* Add a category.
*
* @param CategoryModel $category
*/
public function addCategory(CategoryModel $category): void
{
// spent is minus zero for an expense report:
if ($category->spent < 0) {
$this->categories->push($category);
$this->addTotal((string)$category->spent);
}
}
/**
* Add to the total amount.
*
* @param string $add
*/
public function addTotal(string $add): void
{
$this->total = bcadd($this->total, $add);
}
/**
* Get all categories.
*
* @return Collection
*/
public function getCategories(): Collection
{
$set = $this->categories->sortBy(
static function (CategoryModel $category) {
return $category->spent;
}
);
return $set;
}
/**
* Get the total.
*
* @return string
*/
public function getTotal(): string
{
return $this->total;
}
}

View File

@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Report;
use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Bill as BillCollection;
use FireflyIII\Helpers\Collection\BillLine;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Bill;
@ -117,54 +115,6 @@ class ReportHelper implements ReportHelperInterface
}
return $report;
echo '<pre>';
print_r($report);
exit;
$collection = new BillCollection;
$collection->setStartDate($start);
$collection->setEndDate($end);
/** @var Bill $bill */
foreach ($bills as $bill) {
$expectedDates = $repository->getPayDatesInRange($bill, $start, $end);
foreach ($expectedDates as $payDate) {
$endOfPayPeriod = app('navigation')->endOfX($payDate, $bill->repeat_freq, null);
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($payDate, $endOfPayPeriod)->setBill($bill);
$journals = $collector->getExtractedJournals();
$billLine = new BillLine;
$billLine->setBill($bill);
$billLine->setCurrency($bill->transactionCurrency);
$billLine->setPayDate($payDate);
$billLine->setEndOfPayDate($endOfPayPeriod);
$billLine->setMin((string)$bill->amount_min);
$billLine->setMax((string)$bill->amount_max);
$billLine->setHit(false);
/** @var array $first */
$first = null;
if (count($journals) > 0) {
$first = reset($journals);
}
if (null !== $first) {
$billLine->setTransactionJournalId($first['transaction_journal_id']);
$billLine->setAmount($first['amount']);
$billLine->setLastHitDate($first['date']);
$billLine->setHit(true);
}
if ($billLine->isActive() || $billLine->isHit()) {
$collection->addBill($billLine);
}
}
}
$collection->filterBills();
return $collection;
}
/**