akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -9,48 +9,51 @@ use App\Utilities\Recurring;
class ExpenseSummary extends Report
{
public $default_name = 'reports.summary.expense';
public $default_name = 'reports.expense_summary';
public $icon = 'fa fa-shopping-cart';
public $icon = 'shopping_cart';
public $type = 'summary';
public $chart = [
'line' => [
'width' => '0',
'height' => '300',
'options' => [
'color' => '#ef3232',
'legend' => [
'display' => false,
],
'bar' => [
'colors' => [
'#fb7185',
],
'backgroundColor' => '#ef3232',
'color' => '#ef3232',
],
'donut' => [
//
],
];
public function setTables()
{
$this->tables = [
'expense' => trans_choice('general.expenses', 2),
];
}
public function setData()
{
$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':
// Payments
$payments = $transactions->get();
$this->setTotals($payments, 'paid_at');
// Expenses
$expenses = $transactions->get();
$this->setTotals($expenses, 'paid_at', false, 'expense');
break;
default:
// 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');
$this->setTotals($bills, 'issued_at', false, 'expense');
// Payments
$payments = $transactions->isNotDocument()->get();
Recurring::reflect($payments, 'paid_at');
$this->setTotals($payments, 'paid_at');
// Expenses
$expenses = $transactions->isNotDocument()->get();
Recurring::reflect($expenses, 'paid_at');
$this->setTotals($expenses, 'paid_at', false, 'expense');
break;
}