From 492ae7b7f7493f918cf0b338f71ef6b9b968ea8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Wed, 8 Feb 2023 01:35:41 +0300 Subject: [PATCH 1/3] fixed import validation issue --- app/Traits/Import.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Traits/Import.php b/app/Traits/Import.php index 42a0d9725..95742496b 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -102,7 +102,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new CurrencyRequest)->rules()]); + Validator::validate($data, (new CurrencyRequest)->rules()); $currency = $this->dispatch(new CreateCurrency($data)); @@ -181,7 +181,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new AccountRequest)->rules()]); + Validator::validate($data, (new AccountRequest)->rules()); $account = $this->dispatch(new CreateAccount($data)); @@ -207,7 +207,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new AccountRequest)->rules()]); + Validator::validate($data, (new AccountRequest)->rules()); $account = $this->dispatch(new CreateAccount($data)); @@ -233,7 +233,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new AccountRequest)->rules()]); + Validator::validate($data, (new AccountRequest)->rules()); $account = $this->dispatch(new CreateAccount($data)); @@ -258,7 +258,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new CategoryRequest)->rules()]); + Validator::validate($data, (new CategoryRequest)->rules()); $category = $this->dispatch(new CreateCategory($data)); @@ -284,7 +284,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new ContactRequest)->rules()]); + Validator::validate($data, (new ContactRequest)->rules()); $contact = $this->dispatch(new CreateContact($data)); @@ -310,7 +310,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new ContactRequest)->rules()]); + Validator::validate($data, (new ContactRequest)->rules()); $contact = $this->dispatch(new CreateContact($data)); @@ -335,7 +335,7 @@ trait Import 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new ItemRequest())->rules()]); + Validator::validate($data, (new ItemRequest())->rules()); $item = $this->dispatch(new CreateItem($data)); @@ -354,13 +354,13 @@ trait Import 'company_id' => company_id(), 'rate' => $row['tax_rate'], 'type' => $type, - 'name' => !empty($row['tax_name']) ? $row['tax_name'] : $row['tax_rate'], + 'name' => !empty($row['tax_name']) ? $row['tax_name'] : (string) $row['tax_rate'], 'enabled' => 1, 'created_from' => $row['created_from'], 'created_by' => $row['created_by'], ]; - Validator::validate($data, [(new TaxRequest())->rules()]); + Validator::validate($data, (new TaxRequest())->rules()); $tax = $this->dispatch(new CreateTax($data)); From cdea7ec0702e47476bb4637301bf43595278be8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Wed, 8 Feb 2023 01:36:42 +0300 Subject: [PATCH 2/3] fixed import item issue --- app/Imports/Common/Sheets/ItemTaxes.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/Imports/Common/Sheets/ItemTaxes.php b/app/Imports/Common/Sheets/ItemTaxes.php index ec41d645c..3ea4f2efb 100644 --- a/app/Imports/Common/Sheets/ItemTaxes.php +++ b/app/Imports/Common/Sheets/ItemTaxes.php @@ -4,7 +4,6 @@ namespace App\Imports\Common\Sheets; use App\Abstracts\Import; use App\Http\Requests\Common\ItemTax as Request; -use App\Models\Common\Item; use App\Models\Common\ItemTax as Model; class ItemTaxes extends Import @@ -16,14 +15,14 @@ class ItemTaxes extends Import public function map($row): array { - $row = parent::map($row); - - $row['item_id'] = (int) Item::where('name', $row['item_name'])->value('id'); - - if ($this->isEmpty($row, 'item_id')) { + if ($this->isEmpty($row, 'item_name')) { return []; } + $row = parent::map($row); + + $row['item_id'] = $this->getItemId($row); + $row['tax_id'] = $this->getTaxId($row); return $row; From 9750e0c9b2cadbff653f69ff92b8b3daa214c5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Wed, 8 Feb 2023 01:37:55 +0300 Subject: [PATCH 3/3] fixed import transaction issue --- app/Imports/Banking/Transactions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Imports/Banking/Transactions.php b/app/Imports/Banking/Transactions.php index 5bb9deee9..b710a8e03 100644 --- a/app/Imports/Banking/Transactions.php +++ b/app/Imports/Banking/Transactions.php @@ -17,10 +17,10 @@ class Transactions extends Import { $row = parent::map($row); + $row['currency_code'] = $this->getCurrencyCode($row); $row['account_id'] = $this->getAccountId($row); $row['category_id'] = $this->getCategoryId($row); $row['contact_id'] = $this->getContactId($row); - $row['currency_code'] = $this->getCurrencyCode($row); $row['document_id'] = $this->getDocumentId($row); return $row;