close #1053 Added: Dashboard date filter
This commit is contained in:
@ -137,7 +137,7 @@ class CashFlow extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
$items = Transaction::type($type)->whereBetween('paid_at', [$start, $end])->isNotTransfer()->get();
|
||||
$items = $this->applyFilters(Transaction::type($type)->whereBetween('paid_at', [$start, $end])->isNotTransfer())->get();
|
||||
|
||||
$this->setTotals($totals, $items, $date_format, $period);
|
||||
|
||||
|
@ -16,7 +16,9 @@ class ExpensesByCategory extends Widget
|
||||
Category::with('expense_transactions')->type('expense')->enabled()->each(function ($category) {
|
||||
$amount = 0;
|
||||
|
||||
foreach ($category->expense_transactions as $transacion) {
|
||||
$transactions = $this->applyFilters($category->expense_transactions())->get();
|
||||
|
||||
foreach ($transactions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,9 @@ class IncomeByCategory extends Widget
|
||||
Category::with('income_transacions')->type('income')->enabled()->each(function ($category) {
|
||||
$amount = 0;
|
||||
|
||||
foreach ($category->income_transacions as $transacion) {
|
||||
$transactions = $this->applyFilters($category->income_transacions())->get();
|
||||
|
||||
foreach ($transactions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,11 @@ class LatestExpenses extends Widget
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$transactions = Transaction::with('category')->type('expense')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5)->get();
|
||||
$transactions = $this->applyFilters(Transaction::with('category')->type('expense')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
|
||||
|
||||
return view('widgets.latest_expenses', [
|
||||
'config' => (object) $this->config,
|
||||
'transactions' => $transactions,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ class LatestIncome extends Widget
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$transactions = Transaction::with('category')->type('income')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5)->get();
|
||||
$transactions = $this->applyFilters(Transaction::with('category')->type('income')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
|
||||
|
||||
return view('widgets.latest_income', [
|
||||
'config' => (object) $this->config,
|
||||
'transactions' => $transactions,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ class TotalExpenses extends Widget
|
||||
{
|
||||
$current = $open = $overdue = 0;
|
||||
|
||||
Transaction::type('expense')->isNotTransfer()->each(function ($transaction) use (&$current) {
|
||||
$this->applyFilters(Transaction::type('expense')->isNotTransfer())->each(function ($transaction) use (&$current) {
|
||||
$current += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
Bill::accrued()->notPaid()->each(function ($bill) use (&$open, &$overdue) {
|
||||
$this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open, &$overdue) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill);
|
||||
|
||||
$open += $open_tmp;
|
||||
|
@ -12,11 +12,11 @@ class TotalIncome extends Widget
|
||||
{
|
||||
$current = $open = $overdue = 0;
|
||||
|
||||
Transaction::type('income')->isNotTransfer()->each(function ($transaction) use (&$current) {
|
||||
$this->applyFilters(Transaction::type('income')->isNotTransfer())->each(function ($transaction) use (&$current) {
|
||||
$current += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
Invoice::accrued()->notPaid()->each(function ($invoice) use (&$open, &$overdue) {
|
||||
$this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open, &$overdue) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice);
|
||||
|
||||
$open += $open_tmp;
|
||||
|
@ -14,7 +14,7 @@ class TotalProfit extends Widget
|
||||
$current_income = $open_invoice = $overdue_invoice = 0;
|
||||
$current_expenses = $open_bill = $overdue_bill = 0;
|
||||
|
||||
Transaction::isNotTransfer()->each(function ($transaction) use (&$current_income, &$current_expenses) {
|
||||
$this->applyFilters(Transaction::isNotTransfer())->each(function ($transaction) use (&$current_income, &$current_expenses) {
|
||||
$amount = $transaction->getAmountConvertedToDefault();
|
||||
|
||||
if ($transaction->type == 'income') {
|
||||
@ -24,14 +24,14 @@ class TotalProfit extends Widget
|
||||
}
|
||||
});
|
||||
|
||||
Invoice::accrued()->notPaid()->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) {
|
||||
$this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice);
|
||||
|
||||
$open_invoice += $open_tmp;
|
||||
$overdue_invoice += $overdue_tmp;
|
||||
});
|
||||
|
||||
Bill::accrued()->notPaid()->each(function ($bill) use (&$open_bill, &$overdue_bill) {
|
||||
$this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open_bill, &$overdue_bill) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill);
|
||||
|
||||
$open_bill += $open_tmp;
|
||||
|
Reference in New Issue
Block a user