mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Included bills in month report. [skip ci]
This commit is contained in:
parent
098e5bc162
commit
c9df265c9b
55
app/Helpers/Collection/Bill.php
Normal file
55
app/Helpers/Collection/Bill.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
|
||||
|
||||
use FireflyIII\Models\Bill as BillModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Bill
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
*/
|
||||
class Bill
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $bills;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->bills = new Collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BillLine $bill
|
||||
*/
|
||||
public function addBill(BillLine $bill)
|
||||
{
|
||||
$this->bills->push($bill);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBills()
|
||||
{
|
||||
$this->bills->sortBy(
|
||||
function (BillLine $bill) {
|
||||
$active = intval($bill->getBill()->active) == 0 ? 1 : 0;
|
||||
$name = $bill->getBill()->name;
|
||||
return $active.$name;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return $this->bills;
|
||||
}
|
||||
|
||||
}
|
125
app/Helpers/Collection/BillLine.php
Normal file
125
app/Helpers/Collection/BillLine.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
|
||||
use FireflyIII\Models\Bill as BillModel;
|
||||
|
||||
/**
|
||||
* Class BillLine
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
*/
|
||||
class BillLine
|
||||
{
|
||||
|
||||
/** @var bool */
|
||||
protected $active;
|
||||
/** @var float */
|
||||
protected $amount;
|
||||
/** @var BillModel */
|
||||
protected $bill;
|
||||
/** @var bool */
|
||||
protected $hit;
|
||||
/** @var float */
|
||||
protected $max;
|
||||
/** @var float */
|
||||
protected $min;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $amount
|
||||
*/
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BillModel
|
||||
*/
|
||||
public function getBill()
|
||||
{
|
||||
return $this->bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BillModel $bill
|
||||
*/
|
||||
public function setBill($bill)
|
||||
{
|
||||
$this->bill = $bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getMax()
|
||||
{
|
||||
return $this->max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $max
|
||||
*/
|
||||
public function setMax($max)
|
||||
{
|
||||
$this->max = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getMin()
|
||||
{
|
||||
return $this->min;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $min
|
||||
*/
|
||||
public function setMin($min)
|
||||
{
|
||||
$this->min = $min;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHit()
|
||||
{
|
||||
return $this->hit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $hit
|
||||
*/
|
||||
public function setHit($hit)
|
||||
{
|
||||
$this->hit = $hit;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,12 +9,15 @@ use FireflyIII\Helpers\Collection\Balance;
|
||||
use FireflyIII\Helpers\Collection\BalanceEntry;
|
||||
use FireflyIII\Helpers\Collection\BalanceHeader;
|
||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||
use FireflyIII\Helpers\Collection\BillLine;
|
||||
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
||||
use FireflyIII\Helpers\Collection\BudgetLine;
|
||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
||||
use FireflyIII\Helpers\Collection\Expense;
|
||||
use FireflyIII\Helpers\Collection\Income;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Budget as BudgetModel;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
|
||||
@ -137,17 +140,17 @@ class ReportHelper implements ReportHelperInterface
|
||||
|
||||
// then a new line for without budget.
|
||||
// and one for the tags:
|
||||
$empty = new BalanceLine;
|
||||
$tags = new BalanceLine;
|
||||
$empty = new BalanceLine;
|
||||
$tags = new BalanceLine;
|
||||
$diffLine = new BalanceLine;
|
||||
|
||||
$tags->setRole(BalanceLine::ROLE_TAGROLE);
|
||||
$diffLine->setRole(BalanceLine::ROLE_DIFFROLE);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$spent = $this->query->spentNoBudget($account, $start, $end);
|
||||
$left = $tagRepository->coveredByBalancingActs($account, $start, $end);
|
||||
$diff = $spent + $left;
|
||||
$spent = $this->query->spentNoBudget($account, $start, $end);
|
||||
$left = $tagRepository->coveredByBalancingActs($account, $start, $end);
|
||||
$diff = $spent + $left;
|
||||
|
||||
// budget
|
||||
$budgetEntry = new BalanceEntry;
|
||||
@ -178,6 +181,52 @@ class ReportHelper implements ReportHelperInterface
|
||||
return $balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method generates a full report for the given period on all
|
||||
* the users bills and their payments.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return BillCollection
|
||||
*/
|
||||
public function getBillReport(Carbon $start, Carbon $end, $shared)
|
||||
{
|
||||
/** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */
|
||||
$repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||
$bills = $repository->getBills();
|
||||
$collection = new BillCollection;
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($bills as $bill) {
|
||||
$billLine = new BillLine;
|
||||
$billLine->setBill($bill);
|
||||
$billLine->setActive(intval($bill->active) == 1);
|
||||
$billLine->setMin(floatval($bill->amount_min));
|
||||
$billLine->setMax(floatval($bill->amount_max));
|
||||
|
||||
// is hit in period?
|
||||
$set = $repository->getJournalsInRange($bill, $start, $end);
|
||||
if ($set->count() == 0) {
|
||||
$billLine->setHit(false);
|
||||
} else {
|
||||
$billLine->setHit(true);
|
||||
$amount = 0;
|
||||
foreach ($set as $entry) {
|
||||
$amount += $entry->amount;
|
||||
}
|
||||
$billLine->setAmount($amount);
|
||||
}
|
||||
|
||||
$collection->addBill($billLine);
|
||||
|
||||
}
|
||||
|
||||
return $collection;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -30,6 +30,18 @@ interface ReportHelperInterface
|
||||
*/
|
||||
public function getAccountReport(Carbon $date, Carbon $end, $shared);
|
||||
|
||||
/**
|
||||
* This method generates a full report for the given period on all
|
||||
* the users bills and their payments.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function getBillReport(Carbon $start, Carbon $end, $shared);
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -90,6 +90,7 @@ class ReportController extends Controller
|
||||
$budgets = $this->helper->getBudgetReport($start, $end, $shared);
|
||||
$categories = $this->helper->getCategoryReport($start, $end, $shared);
|
||||
$balance = $this->helper->getBalanceReport($start, $end, $shared);
|
||||
$bills = $this->helper->getBillReport($start, $end, $shared);
|
||||
|
||||
|
||||
return view(
|
||||
@ -101,7 +102,8 @@ class ReportController extends Controller
|
||||
'incomes', 'incomeTopLength',
|
||||
'expenses', 'expenseTopLength',
|
||||
'budgets', 'balance',
|
||||
'categories'
|
||||
'categories',
|
||||
'bills'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -111,7 +111,8 @@ return [
|
||||
'leftInBudget' => 'Left in budget',
|
||||
|
||||
'sumOfSums' => 'Sum of sums',
|
||||
|
||||
'notCharged' => 'Not charged (yet)',
|
||||
'inactive' => 'Inactive',
|
||||
|
||||
'difference' => 'Difference',
|
||||
'in' => 'In',
|
||||
|
@ -36,6 +36,7 @@ return [
|
||||
'remind_me' => 'Remind me',
|
||||
'tag' => 'Tag',
|
||||
'reminder' => 'Remind me every',
|
||||
'under' => 'Under',
|
||||
|
||||
'store_new_withdrawal' => 'Store new withdrawal',
|
||||
'store_new_deposit' => 'Store new deposit',
|
||||
|
@ -112,6 +112,8 @@ return [
|
||||
'leftInBudget' => 'Over van budget',
|
||||
|
||||
'sumOfSums' => 'Alles bij elkaar',
|
||||
'notCharged' => '(Nog) niet betaald',
|
||||
'inactive' => 'Niet actief',
|
||||
|
||||
'difference' => 'Verschil',
|
||||
'in' => 'In',
|
||||
|
@ -36,6 +36,7 @@ return [
|
||||
'remind_me' => 'Help me herinneren',
|
||||
'tag' => 'Tag',
|
||||
'reminder' => 'Herinner me elke',
|
||||
'under' => 'Onder',
|
||||
|
||||
'store_new_withdrawal' => 'Nieuwe uitgave opslaan',
|
||||
'store_new_deposit' => 'Nieuwe inkomsten opslaan',
|
||||
|
51
resources/twig/partials/reports/bills.twig
Normal file
51
resources/twig/partials/reports/bills.twig
Normal file
@ -0,0 +1,51 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-calendar-o fa-fw"></i>
|
||||
{{ 'bills'|_ }}
|
||||
</div>
|
||||
<table class="table table-bordered table-striped sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ trans('form.name') }}</th>
|
||||
<th>{{ trans('form.amount_min') }}</th>
|
||||
<th>{{ trans('form.amount_max') }}</th>
|
||||
<th>{{ trans('form.amount') }}</th>
|
||||
<th>{{ trans('form.under') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for line in bills.getBills %}
|
||||
{% if not line.isActive %}
|
||||
<tr class="text-muted">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td data-value="{{ line.getBill.name }}">
|
||||
<a href="{{ route('bills.show',line.getBill.id) }}">{{ line.getBill.name }}</a>
|
||||
{% if not line.isActive %}
|
||||
({{ 'inactive'|_|lower }})
|
||||
{% endif %}
|
||||
</td>
|
||||
<td data-value="{{ line.getMin }}">{{ line.getMin|formatAmount }}</td>
|
||||
<td data-value="{{ line.getMax }}">{{ line.getMax|formatAmount }}</td>
|
||||
{% if line.isHit %}
|
||||
<td data-value="{{ line.getAmount }}">{{ line.getAmount|formatAmount }}</td>
|
||||
{% endif %}
|
||||
{% if not line.isHit and line.isActive %}
|
||||
<td data-value="0" class="bg-success">{{ 'notCharged'|_ }}</td>
|
||||
{% endif %}
|
||||
{% if not line.isActive %}
|
||||
<td data-value="-1"> </td>
|
||||
{% endif %}
|
||||
<td data-value="{{ (line.getMax - line.getAmount) }}">
|
||||
{% if line.isActive %}
|
||||
{{ (line.getMax - line.getAmount)|formatAmount }}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -52,13 +52,8 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-calendar-o fa-fw"></i>
|
||||
{{ 'bills'|_ }}
|
||||
</div>
|
||||
<div class="panel-body">Body</div>
|
||||
</div>
|
||||
{% include 'partials/reports/bills.twig' %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user