basis filter added to reports
This commit is contained in:
parent
69aeb32fae
commit
8bdb6e2e98
@ -114,6 +114,14 @@ abstract class Report
|
|||||||
return $model->pluck('name', 'id')->toArray();
|
return $model->pluck('name', 'id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBasis()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'cash' => trans('general.cash'),
|
||||||
|
'accrual' => trans('general.accrual'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function applyDateFilter($event)
|
public function applyDateFilter($event)
|
||||||
{
|
{
|
||||||
$event->model->monthsOfYear($event->args['date_field']);
|
$event->model->monthsOfYear($event->args['date_field']);
|
||||||
@ -127,6 +135,10 @@ abstract class Report
|
|||||||
$search_year = 'year:' . $this->getSearchStringValue('year', '', $input);
|
$search_year = 'year:' . $this->getSearchStringValue('year', '', $input);
|
||||||
$input = str_replace($search_year, '', $input);
|
$input = str_replace($search_year, '', $input);
|
||||||
|
|
||||||
|
// Remove basis as it's handled based on report itself
|
||||||
|
$search_basis = 'basis:' . $this->getSearchStringValue('basis', 'accrual', $input);
|
||||||
|
$input = str_replace($search_basis, '', $input);
|
||||||
|
|
||||||
$event->model->usingSearchString($input);
|
$event->model->usingSearchString($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
app/Listeners/Report/AddBasis.php
Normal file
34
app/Listeners/Report/AddBasis.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners\Report;
|
||||||
|
|
||||||
|
use App\Abstracts\Listeners\Report as Listener;
|
||||||
|
use App\Events\Report\FilterShowing;
|
||||||
|
|
||||||
|
class AddBasis extends Listener
|
||||||
|
{
|
||||||
|
protected $classes = [
|
||||||
|
'App\Reports\IncomeSummary',
|
||||||
|
'App\Reports\ExpenseSummary',
|
||||||
|
'App\Reports\IncomeExpenseSummary',
|
||||||
|
'App\Reports\ProfitLoss',
|
||||||
|
'App\Reports\TaxSummary',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle filter showing event.
|
||||||
|
*
|
||||||
|
* @param $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handleFilterShowing(FilterShowing $event)
|
||||||
|
{
|
||||||
|
if ($this->skipThisClass($event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$event->class->filters['basis'] = $this->getBasis();
|
||||||
|
$event->class->filters['keys']['basis'] = 'basis';
|
||||||
|
$event->class->filters['defaults']['basis'] = $event->class->getSetting('basis', 'accrual');
|
||||||
|
}
|
||||||
|
}
|
@ -111,5 +111,6 @@ class Event extends Provider
|
|||||||
'App\Listeners\Report\AddIncomeExpenseCategories',
|
'App\Listeners\Report\AddIncomeExpenseCategories',
|
||||||
'App\Listeners\Report\AddSearchString',
|
'App\Listeners\Report\AddSearchString',
|
||||||
'App\Listeners\Report\AddRowsToTax',
|
'App\Listeners\Report\AddRowsToTax',
|
||||||
|
'App\Listeners\Report\AddBasis',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,9 @@ class ExpenseSummary extends Report
|
|||||||
{
|
{
|
||||||
$transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
switch ($this->getSetting('basis')) {
|
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||||
|
|
||||||
|
switch ($basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
// Payments
|
// Payments
|
||||||
$payments = $transactions->get();
|
$payments = $transactions->get();
|
||||||
|
@ -18,7 +18,9 @@ class IncomeExpenseSummary extends Report
|
|||||||
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
switch ($this->getSetting('basis')) {
|
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||||
|
|
||||||
|
switch ($basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
// Revenues
|
// Revenues
|
||||||
$revenues = $income_transactions->get();
|
$revenues = $income_transactions->get();
|
||||||
|
@ -32,7 +32,9 @@ class IncomeSummary extends Report
|
|||||||
{
|
{
|
||||||
$transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
switch ($this->getSetting('basis')) {
|
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||||
|
|
||||||
|
switch ($basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
// Revenues
|
// Revenues
|
||||||
$revenues = $transactions->get();
|
$revenues = $transactions->get();
|
||||||
|
@ -37,7 +37,9 @@ class ProfitLoss extends Report
|
|||||||
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
switch ($this->getSetting('basis')) {
|
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||||
|
|
||||||
|
switch ($basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
// Revenues
|
// Revenues
|
||||||
$revenues = $income_transactions->get();
|
$revenues = $income_transactions->get();
|
||||||
|
@ -40,7 +40,9 @@ class TaxSummary extends Report
|
|||||||
|
|
||||||
public function setData()
|
public function setData()
|
||||||
{
|
{
|
||||||
switch ($this->getSetting('basis')) {
|
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||||
|
|
||||||
|
switch ($basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
// Invoice Payments
|
// Invoice Payments
|
||||||
$invoices = $this->applyFilters(Transaction::with('recurring', 'invoice', 'invoice.totals')->income()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
$invoices = $this->applyFilters(Transaction::with('recurring', 'invoice', 'invoice.totals')->income()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user