akaunting 3.0 (the last dance)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -9,48 +9,51 @@ use App\Utilities\Recurring;
|
||||
|
||||
class IncomeSummary extends Report
|
||||
{
|
||||
public $default_name = 'reports.summary.income';
|
||||
public $default_name = 'reports.income_summary';
|
||||
|
||||
public $icon = 'fa fa-money-bill';
|
||||
public $icon = 'payments';
|
||||
|
||||
public $type = 'summary';
|
||||
|
||||
public $chart = [
|
||||
'line' => [
|
||||
'width' => '0',
|
||||
'height' => '300',
|
||||
'options' => [
|
||||
'color' => '#328aef',
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
'bar' => [
|
||||
'colors' => [
|
||||
'#8bb475',
|
||||
],
|
||||
'backgroundColor' => '#328aef',
|
||||
'color' => '#328aef',
|
||||
],
|
||||
'donut' => [
|
||||
//
|
||||
],
|
||||
];
|
||||
|
||||
public function setTables()
|
||||
{
|
||||
$this->tables = [
|
||||
'income' => trans_choice('general.incomes', 1),
|
||||
];
|
||||
}
|
||||
|
||||
public function setData()
|
||||
{
|
||||
$transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
|
||||
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||
|
||||
switch ($basis) {
|
||||
switch ($this->getBasis()) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$revenues = $transactions->get();
|
||||
$this->setTotals($revenues, 'paid_at');
|
||||
// Incomes
|
||||
$incomes = $transactions->get();
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income');
|
||||
|
||||
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');
|
||||
$this->setTotals($invoices, 'issued_at', false, 'income');
|
||||
|
||||
// Revenues
|
||||
$revenues = $transactions->isNotDocument()->get();
|
||||
Recurring::reflect($revenues, 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at');
|
||||
// Incomes
|
||||
$incomes = $transactions->isNotDocument()->get();
|
||||
Recurring::reflect($incomes, 'paid_at');
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income');
|
||||
|
||||
break;
|
||||
}
|
||||
|
@@ -13,15 +13,19 @@ class ProfitLoss extends Report
|
||||
|
||||
public $category = 'general.accounting';
|
||||
|
||||
public $icon = 'fa fa-heart';
|
||||
public $icon = 'favorite_border';
|
||||
|
||||
public $type = 'detail';
|
||||
|
||||
public $chart = false;
|
||||
|
||||
public function setViews()
|
||||
{
|
||||
parent::setViews();
|
||||
$this->views['content.header'] = 'reports.profit_loss.content.header';
|
||||
$this->views['content.footer'] = 'reports.profit_loss.content.footer';
|
||||
$this->views['table.header'] = 'reports.profit_loss.table.header';
|
||||
$this->views['table.footer'] = 'reports.profit_loss.table.footer';
|
||||
$this->views['detail.content.header'] = 'reports.profit_loss.content.header';
|
||||
$this->views['detail.content.footer'] = 'reports.profit_loss.content.footer';
|
||||
$this->views['detail.table.header'] = 'reports.profit_loss.table.header';
|
||||
$this->views['detail.table.footer'] = 'reports.profit_loss.table.footer';
|
||||
}
|
||||
|
||||
public function setTables()
|
||||
@@ -37,50 +41,60 @@ class ProfitLoss extends Report
|
||||
$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, $this->tables['income'], false);
|
||||
// Incomes
|
||||
$incomes = $income_transactions->get();
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income', false);
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->get();
|
||||
$this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
|
||||
// Expenses
|
||||
$expenses = $expense_transactions->get();
|
||||
$this->setTotals($expenses, 'paid_at', false, 'expense', false);
|
||||
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at', true, $this->tables['income'], false);
|
||||
$this->setTotals($invoices, 'issued_at', false, 'income', false);
|
||||
|
||||
// Revenues
|
||||
$revenues = $income_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($revenues, 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
|
||||
// Incomes
|
||||
$incomes = $income_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($incomes, 'paid_at');
|
||||
$this->setTotals($incomes, 'paid_at', false, 'income', false);
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at', true, $this->tables['expense'], false);
|
||||
$this->setTotals($bills, 'issued_at', false, 'expense', false);
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($payments, 'paid_at');
|
||||
$this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
|
||||
// Expenses
|
||||
$expenses = $expense_transactions->isNotDocument()->get();
|
||||
Recurring::reflect($expenses, 'paid_at');
|
||||
$this->setTotals($expenses, 'paid_at', false, 'expense', false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$this->setNetProfit();
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
public function setNetProfit()
|
||||
{
|
||||
return [
|
||||
$this->getGroupField(),
|
||||
$this->getPeriodField(),
|
||||
$this->getBasisField(),
|
||||
];
|
||||
foreach ($this->footer_totals as $table => $dates) {
|
||||
foreach ($dates as $date => $total) {
|
||||
if (!isset($this->net_profit[$date])) {
|
||||
$this->net_profit[$date] = 0;
|
||||
}
|
||||
|
||||
if ($table == 'income') {
|
||||
$this->net_profit[$date] += $total;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->net_profit[$date] -= $total;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,19 +14,23 @@ class TaxSummary extends Report
|
||||
{
|
||||
use Currencies;
|
||||
|
||||
public $default_name = 'reports.summary.tax';
|
||||
public $default_name = 'reports.tax_summary';
|
||||
|
||||
public $category = 'general.accounting';
|
||||
|
||||
public $icon = 'fa fa-percent';
|
||||
public $icon = 'percent';
|
||||
|
||||
public $type = 'detail';
|
||||
|
||||
public $chart = false;
|
||||
|
||||
public function setViews()
|
||||
{
|
||||
parent::setViews();
|
||||
$this->views['content.header'] = 'reports.tax_summary.content.header';
|
||||
$this->views['content.footer'] = 'reports.tax_summary.content.footer';
|
||||
$this->views['table.header'] = 'reports.tax_summary.table.header';
|
||||
$this->views['table.footer'] = 'reports.tax_summary.table.footer';
|
||||
$this->views['detail.content.header'] = 'reports.tax_summary.content.header';
|
||||
$this->views['detail.content.footer'] = 'reports.tax_summary.content.footer';
|
||||
$this->views['detail.table.header'] = 'reports.tax_summary.table.header';
|
||||
$this->views['detail.table.footer'] = 'reports.tax_summary.table.footer';
|
||||
}
|
||||
|
||||
public function setTables()
|
||||
@@ -40,9 +44,7 @@ class TaxSummary extends Report
|
||||
|
||||
public function setData()
|
||||
{
|
||||
$basis = $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||
|
||||
switch ($basis) {
|
||||
switch ($this->getBasis()) {
|
||||
case 'cash':
|
||||
// Invoice Payments
|
||||
$invoices = $this->applyFilters(Transaction::with('recurring', 'invoice', 'invoice.totals')->income()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
|
Reference in New Issue
Block a user