improved document import
This commit is contained in:
parent
96fd43384a
commit
7a10757c8d
@ -11,7 +11,7 @@ class Transactions extends Export implements WithColumnFormatting
|
|||||||
{
|
{
|
||||||
public function collection()
|
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)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $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->account_name = $model->account->name;
|
||||||
$model->contact_email = $model->contact->email;
|
$model->contact_email = $model->contact->email;
|
||||||
$model->category_name = $model->category->name;
|
$model->category_name = $model->category->name;
|
||||||
|
$model->invoice_bill_number = $model->document->document_number ?? 0;
|
||||||
if ($model->type == 'income') {
|
|
||||||
$model->invoice_bill_number = $model->invoice->document_number ?? 0;
|
|
||||||
} else {
|
|
||||||
$model->invoice_bill_number = $model->bill->document_number ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::map($model);
|
return parent::map($model);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,10 @@ trait Import
|
|||||||
{
|
{
|
||||||
$id = isset($row['document_id']) ? $row['document_id'] : null;
|
$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'])) {
|
if (empty($id) && !empty($row['invoice_number'])) {
|
||||||
$id = Document::invoice()->number($row['invoice_number'])->pluck('id')->first();
|
$id = Document::invoice()->number($row['invoice_number'])->pluck('id')->first();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user