close #1880 Fixed: Reports Not all categories are displayed

This commit is contained in:
Cüneyt Şentürk
2021-02-27 21:03:56 +03:00
parent e4a461ac89
commit 587dde8a3a
7 changed files with 69 additions and 36 deletions

View File

@ -51,49 +51,67 @@ abstract class Report
return $years;
}
public function getAccounts()
public function getAccounts($limit = false)
{
return Account::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id')->toArray();
$model = Account::enabled()->orderBy('name');
if ($limit !== false) {
$model->take(setting('default.select_limit'));
}
return $model->pluck('name', 'id')->toArray();
}
public function getItemCategories()
public function getItemCategories($limit = false)
{
return $this->getCategories('item');
return $this->getCategories('item', $limit);
}
public function getIncomeCategories()
public function getIncomeCategories($limit = false)
{
return $this->getCategories('income');
return $this->getCategories('income', $limit);
}
public function getExpenseCategories()
public function getExpenseCategories($limit = false)
{
return $this->getCategories('expense');
return $this->getCategories('expense', $limit);
}
public function getIncomeExpenseCategories()
public function getIncomeExpenseCategories($limit = false)
{
return $this->getCategories(['income', 'expense']);
return $this->getCategories(['income', 'expense'], $limit);
}
public function getCategories($types)
public function getCategories($types, $limit = false)
{
return Category::type($types)->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id')->toArray();
$model = Category::type($types)->orderBy('name');
if ($limit !== false) {
$model->take(setting('default.select_limit'));
}
return $model->pluck('name', 'id')->toArray();
}
public function getCustomers()
public function getCustomers($limit = false)
{
return $this->getContacts($this->getCustomerTypes());
return $this->getContacts($this->getCustomerTypes(), $limit);
}
public function getVendors()
public function getVendors($limit = false)
{
return $this->getContacts($this->getVendorTypes());
return $this->getContacts($this->getVendorTypes(), $limit);
}
public function getContacts($types)
public function getContacts($types, $limit = false)
{
return Contact::type($types)->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id')->toArray();
$model = Contact::type($types)->orderBy('name');
if ($limit !== false) {
$model->take(setting('default.select_limit'));
}
return $model->pluck('name', 'id')->toArray();
}
public function applyDateFilter($event)