added parent id field to import and export

This commit is contained in:
Cihan Şentürk
2023-07-20 15:39:23 +03:00
committed by GitHub
parent 7768280ea3
commit 6a07f8ad9e
7 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,7 @@ use App\Jobs\Setting\CreateCurrency;
use App\Jobs\Setting\CreateTax;
use App\Models\Auth\User;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Common\Contact;
use App\Models\Common\Item;
use App\Models\Document\Document;
@ -149,6 +150,21 @@ trait Import
return is_null($id) ? $id : (int) $id;
}
public function getParentId($row)
{
$id = isset($row['parent_id']) ? $row['parent_id'] : null;
if (empty($id) && isset($row['document_number']) && !empty($row['parent_number'])) {
$id = Document::number($row['parent_number'])->pluck('id')->first();
}
if (empty($id) && isset($row['number']) && !empty($row['parent_number'])) {
$id = Transaction::number($row['parent_number'])->pluck('id')->first();
}
return is_null($id) ? $id : (int) $id;
}
public function getItemId($row, $type = null)
{
$id = isset($row['item_id']) ? $row['item_id'] : null;