import and export parent number issues fixed

This commit is contained in:
Cihan Şentürk 2023-07-24 14:55:44 +03:00 committed by GitHub
parent ceb04a546f
commit ab4c59082f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -26,7 +26,7 @@ class Bills extends Export implements WithColumnFormatting
$model->bill_number = $model->document_number; $model->bill_number = $model->document_number;
$model->billed_at = $model->issued_at; $model->billed_at = $model->issued_at;
$model->contact_country = $country; $model->contact_country = $country;
$model->parent_number = Model::billRecurring()->find($model->parent_id)?->document_number ?? null; $model->parent_number = Model::billRecurring()->find($model->parent_id)?->document_number;
return parent::map($model); return parent::map($model);
} }
@ -53,7 +53,7 @@ class Bills extends Export implements WithColumnFormatting
'contact_zip_code', 'contact_zip_code',
'contact_city', 'contact_city',
'notes', 'notes',
'parent_number', 'parent_number'
]; ];
} }

View File

@ -35,7 +35,7 @@ class Bills extends Import
$row['currency_code'] = $this->getCurrencyCode($row); $row['currency_code'] = $this->getCurrencyCode($row);
$row['type'] = Model::BILL_TYPE; $row['type'] = Model::BILL_TYPE;
$row['contact_country'] = !empty($country) ? $country : null; $row['contact_country'] = !empty($country) ? $country : null;
$row['parent_id'] = $this->getParentId($row); $row['parent_id'] = $this->getParentId($row) ?? 0;
return $row; return $row;
} }

View File

@ -35,7 +35,7 @@ class Invoices extends Import
$row['currency_code'] = $this->getCurrencyCode($row); $row['currency_code'] = $this->getCurrencyCode($row);
$row['type'] = Model::INVOICE_TYPE; $row['type'] = Model::INVOICE_TYPE;
$row['contact_country'] = !empty($country) ? $country : null; $row['contact_country'] = !empty($country) ? $country : null;
$row['parent_id'] = $this->getParentId($row); $row['parent_id'] = $this->getParentId($row) ?? 0;
return $row; return $row;
} }

View File

@ -154,11 +154,15 @@ trait Import
{ {
$id = isset($row['parent_id']) ? $row['parent_id'] : null; $id = isset($row['parent_id']) ? $row['parent_id'] : null;
if (empty($id) && isset($row['document_number']) && !empty($row['parent_number'])) { if (empty($row['parent_number'])) {
return null;
}
if (empty($id) && (!empty($row['document_number']) || !empty($row['invoice_number']) || !empty($row['bill_number']))) {
$id = Document::number($row['parent_number'])->pluck('id')->first(); $id = Document::number($row['parent_number'])->pluck('id')->first();
} }
if (empty($id) && isset($row['number']) && !empty($row['parent_number'])) { if (empty($id) && isset($row['number'])) {
$id = Transaction::number($row['parent_number'])->pluck('id')->first(); $id = Transaction::number($row['parent_number'])->pluck('id')->first();
} }