-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c64dfda
commit c208c33
Showing
12 changed files
with
299 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Common; | ||
|
||
use App\Abstracts\Listeners\Report as Listener; | ||
use App\Events\Common\ReportFilterApplying; | ||
use App\Events\Common\ReportFilterShowing; | ||
|
||
class AddDateToReports 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 handleReportFilterShowing(ReportFilterShowing $event) | ||
{ | ||
if ($this->skipThisClass($event)) { | ||
return; | ||
} | ||
|
||
$event->class->filters['years'] = $this->getYears(); | ||
} | ||
|
||
/** | ||
* Handle filter applying event. | ||
* | ||
* @param $event | ||
* @return void | ||
*/ | ||
public function handleReportFilterApplying(ReportFilterApplying $event) | ||
{ | ||
if ($this->skipThisClass($event)) { | ||
return; | ||
} | ||
|
||
// Apply date | ||
$this->applyDateFilter($event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Common; | ||
|
||
use App\Abstracts\Listeners\Report as Listener; | ||
use App\Events\Common\ReportFilterShowing; | ||
use App\Events\Common\ReportGroupShowing; | ||
|
||
class AddExpenseCategoriesToReports extends Listener | ||
{ | ||
/** | ||
* Handle filter showing event. | ||
* | ||
* @param $event | ||
* @return void | ||
*/ | ||
public function handleReportFilterShowing(ReportFilterShowing $event) | ||
{ | ||
$classes = [ | ||
'App\Reports\ExpenseSummary', | ||
'App\Reports\IncomeExpenseSummary', | ||
]; | ||
|
||
if (empty($event->class) || !in_array(get_class($event->class), $classes)) { | ||
return; | ||
} | ||
|
||
$categories = !empty($event->class->filters['categories']) ? $event->class->filters['categories'] : []; | ||
|
||
$event->class->filters['categories'] = array_merge($categories, $this->getExpenseCategories()); | ||
} | ||
|
||
/** | ||
* Handle group showing event. | ||
* | ||
* @param $event | ||
* @return void | ||
*/ | ||
public function handleReportGroupShowing(ReportGroupShowing $event) | ||
{ | ||
$classes = [ | ||
'App\Reports\ExpenseSummary', | ||
'App\Reports\IncomeExpenseSummary', | ||
'App\Reports\ProfitLoss', | ||
'App\Reports\TaxSummary', | ||
]; | ||
|
||
if (empty($event->class) || !in_array(get_class($event->class), $classes)) { | ||
return; | ||
} | ||
|
||
$event->class->groups['category'] = trans_choice('general.categories', 1); | ||
} | ||
} |
Oops, something went wrong.