akaunting 3.0 (the last dance)
This commit is contained in:
@ -9,48 +9,79 @@ use App\Utilities\Recurring;
|
||||
|
||||
class IncomeExpenseSummary extends Report
|
||||
{
|
||||
public $default_name = 'reports.summary.income_expense';
|
||||
public $default_name = 'reports.income_expense_summary';
|
||||
|
||||
public $icon = 'fa fa-chart-pie';
|
||||
public $icon = 'assessment';
|
||||
|
||||
public $type = 'summary';
|
||||
|
||||
public $chart = [
|
||||
'income' => [
|
||||
'bar' => [
|
||||
'colors' => [
|
||||
'#8bb475',
|
||||
],
|
||||
],
|
||||
'donut' => [
|
||||
//
|
||||
],
|
||||
],
|
||||
'expense' => [
|
||||
'bar' => [
|
||||
'colors' => [
|
||||
'#fb7185',
|
||||
],
|
||||
],
|
||||
'donut' => [
|
||||
//
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function setTables()
|
||||
{
|
||||
$this->tables = [
|
||||
'income' => trans_choice('general.incomes', 1),
|
||||
'expense' => trans_choice('general.expenses', 2),
|
||||
];
|
||||
}
|
||||
|
||||
public function setData()
|
||||
{
|
||||
$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']);
|
||||
|
||||
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||
|
||||
switch ($basis) {
|
||||
switch ($this->getBasis()) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$revenues = $income_transactions->get();
|
||||
$this->setTotals($revenues, 'paid_at', true);
|
||||
// Incomes
|
||||
$incomes = $income_transactions->get();
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income');
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->get();
|
||||
$this->setTotals($payments, 'paid_at', true);
|
||||
// Expenses
|
||||
$expenses = $expense_transactions->get();
|
||||
$this->setTotals($expenses, 'paid_at', false, 'expense');
|
||||
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at', true);
|
||||
$this->setTotals($invoices, 'issued_at', false, 'income');
|
||||
|
||||
// Revenues
|
||||
$revenues = $income_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($revenues, 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at', true);
|
||||
// Incomes
|
||||
$incomes = $income_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($incomes, 'paid_at');
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income');
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at', true);
|
||||
$this->setTotals($bills, 'issued_at', false, 'expense');
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($payments, 'paid_at');
|
||||
$this->setTotals($payments, 'paid_at', true);
|
||||
// Expenses
|
||||
$expenses = $expense_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($expenses, 'paid_at');
|
||||
$this->setTotals($expenses, 'paid_at', false, 'expense');
|
||||
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user