Skip to content

Commit

Permalink
updated import created_by and created_from fields
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanSenturk committed Mar 22, 2023
1 parent 831864f commit 38f848f
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions app/Traits/Import.php
Expand Up @@ -22,11 +22,12 @@
use App\Models\Setting\Currency;
use App\Models\Setting\Tax;
use App\Traits\Jobs;
use App\Traits\Sources;
use Illuminate\Support\Facades\Validator;

trait Import
{
use Jobs;
use Jobs, Sources;

public function getAccountId($row)
{
Expand Down Expand Up @@ -98,8 +99,8 @@ public function getCurrencyCode($row)
'symbol' => isset($row['currency_symbol']) ? $row['currency_symbol'] : config('money.' . $row['currency_code'] . '.symbol'),
'precision' => isset($row['currency_precision']) ? $row['currency_precision'] : config('money.' . $row['currency_code'] . '.precision'),
'decimal_mark' => isset($row['currency_decimal_mark']) ? $row['currency_decimal_mark'] : config('money.' . $row['currency_code'] . '.decimal_mark'),
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new CurrencyRequest)->rules());
Expand Down Expand Up @@ -178,8 +179,8 @@ public function getAccountIdFromCurrency($row)
'number' => !empty($row['account_number']) ? $row['account_number'] : (string) rand(1, 10000),
'opening_balance' => !empty($row['opening_balance']) ? $row['opening_balance'] : 0,
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new AccountRequest)->rules());
Expand All @@ -205,8 +206,8 @@ public function getAccountIdFromName($row)
'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : default_currency(),
'opening_balance' => !empty($row['opening_balance']) ? $row['opening_balance'] : 0,
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new AccountRequest)->rules());
Expand All @@ -232,8 +233,8 @@ public function getAccountIdFromNumber($row)
'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : default_currency(),
'opening_balance' => !empty($row['opening_balance']) ? $row['opening_balance'] : 0,
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new AccountRequest)->rules());
Expand All @@ -257,8 +258,8 @@ public function getCategoryIdFromName($row, $type)
'type' => $type,
'color' => !empty($row['category_color']) ? $row['category_color'] : '#' . dechex(rand(0x000000, 0xFFFFFF)),
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new CategoryRequest)->rules());
Expand All @@ -283,8 +284,8 @@ public function getContactIdFromEmail($row, $type)
'name' => !empty($row['contact_name']) ? $row['contact_name'] : $row['contact_email'],
'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : default_currency(),
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new ContactRequest)->rules());
Expand All @@ -309,8 +310,8 @@ public function getContactIdFromName($row, $type)
'email' => !empty($row['contact_email']) ? $row['contact_email'] : null,
'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : default_currency(),
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new ContactRequest)->rules());
Expand All @@ -336,8 +337,8 @@ public function getItemIdFromName($row)
'sale_price' => !empty($row['sale_price']) ? $row['sale_price'] : (!empty($row['price']) ? $row['price'] : 0),
'purchase_price' => !empty($row['purchase_price']) ? $row['purchase_price'] : (!empty($row['price']) ? $row['price'] : 0),
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new ItemRequest())->rules());
Expand All @@ -361,8 +362,8 @@ public function getTaxIdFromRate($row, $type = 'normal')
'type' => $type,
'name' => !empty($row['tax_name']) ? $row['tax_name'] : (string) $row['tax_rate'],
'enabled' => 1,
'created_from' => $row['created_from'],
'created_by' => $row['created_by'],
'created_from' => !empty($row['created_from']) ? $row['created_from'] : $this->getSourcePrefix() . 'import',
'created_by' => !empty($row['created_by']) ? $row['created_by'] : user()->id,
];

Validator::validate($data, (new TaxRequest())->rules());
Expand Down

0 comments on commit 38f848f

Please sign in to comment.