diff --git a/app/Exports/Purchases/Sheets/BillTransactions.php b/app/Exports/Purchases/Sheets/BillTransactions.php index 54be9dbe3..d295a1e10 100644 --- a/app/Exports/Purchases/Sheets/BillTransactions.php +++ b/app/Exports/Purchases/Sheets/BillTransactions.php @@ -11,7 +11,7 @@ class BillTransactions extends Export implements WithColumnFormatting { public function collection() { - $model = Model::with('account', 'category', 'contact', 'document')->bill()->isDocument()->usingSearchString(request('search')); + $model = Model::with('account', 'category', 'contact', 'document')->expense()->isDocument()->usingSearchString(request('search')); if (!empty($this->ids)) { $model->whereIn('document_id', (array) $this->ids); diff --git a/app/Exports/Sales/Sheets/InvoiceTransactions.php b/app/Exports/Sales/Sheets/InvoiceTransactions.php index dff86c8be..b5aceb1d4 100644 --- a/app/Exports/Sales/Sheets/InvoiceTransactions.php +++ b/app/Exports/Sales/Sheets/InvoiceTransactions.php @@ -13,7 +13,7 @@ class InvoiceTransactions extends Export implements WithColumnFormatting { public function collection() { - $model = Model::with('account', 'category', 'contact', 'document')->invoice()->isDocument()->usingSearchString(request('search')); + $model = Model::with('account', 'category', 'contact', 'document')->income()->isDocument()->usingSearchString(request('search')); if (!empty($this->ids)) { $model->whereIn('document_id', (array) $this->ids); diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index e56806cad..e2378487b 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -131,7 +131,8 @@ class Document extends Model public function transactions() { - return $this->hasMany('App\Models\Banking\Transaction', 'document_id')->where('type', 'income'); + return $this->hasMany('App\Models\Banking\Transaction', 'document_id') + ->where('type', config('type.' . $this->type . '.transaction_type')); } public function totals_sorted()