diff --git a/app/Exports/Banking/Transactions.php b/app/Exports/Banking/Transactions.php index d2e7a0ffc..01354dd74 100644 --- a/app/Exports/Banking/Transactions.php +++ b/app/Exports/Banking/Transactions.php @@ -11,7 +11,7 @@ class Transactions extends Export implements WithColumnFormatting { public function collection() { - $model = Model::with('account', 'bill', 'category', 'contact', 'invoice')->usingSearchString(request('search')); + $model = Model::with('account', 'category', 'contact', 'document')->usingSearchString(request('search')); if (!empty($this->ids)) { $model->whereIn('id', (array) $this->ids); @@ -25,12 +25,7 @@ class Transactions extends Export implements WithColumnFormatting $model->account_name = $model->account->name; $model->contact_email = $model->contact->email; $model->category_name = $model->category->name; - - if ($model->type == 'income') { - $model->invoice_bill_number = $model->invoice->document_number ?? 0; - } else { - $model->invoice_bill_number = $model->bill->document_number ?? 0; - } + $model->invoice_bill_number = $model->document->document_number ?? 0; return parent::map($model); } diff --git a/app/Traits/Import.php b/app/Traits/Import.php index 15b5b290c..042ce58c8 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -64,6 +64,10 @@ trait Import { $id = isset($row['document_id']) ? $row['document_id'] : null; + if (empty($id) && !empty($row['document_number'])) { + $id = Document::number($row['document_number'])->pluck('id')->first(); + } + if (empty($id) && !empty($row['invoice_number'])) { $id = Document::invoice()->number($row['invoice_number'])->pluck('id')->first(); }