2020-01-20 22:58:49 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Imports\Sales\Sheets;
|
|
|
|
|
|
|
|
use App\Abstracts\Import;
|
|
|
|
use App\Http\Requests\Banking\Transaction as Request;
|
|
|
|
use App\Models\Banking\Transaction as Model;
|
|
|
|
|
|
|
|
class InvoiceTransactions extends Import
|
|
|
|
{
|
|
|
|
public function model(array $row)
|
|
|
|
{
|
|
|
|
return new Model($row);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function map($row): array
|
|
|
|
{
|
2020-02-25 14:56:48 +03:00
|
|
|
if ($this->isEmpty($row, 'invoice_number')) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-01-20 22:58:49 +03:00
|
|
|
$row = parent::map($row);
|
|
|
|
|
|
|
|
$row['type'] = 'income';
|
2020-01-21 09:10:12 +03:00
|
|
|
$row['account_id'] = $this->getAccountId($row);
|
|
|
|
$row['category_id'] = $this->getCategoryId($row, 'income');
|
|
|
|
$row['contact_id'] = $this->getContactId($row, 'customer');
|
2022-07-19 12:09:04 +03:00
|
|
|
$row['currency_code'] = $this->getCurrencyCode($row);
|
2020-01-21 09:10:12 +03:00
|
|
|
$row['document_id'] = $this->getDocumentId($row);
|
2022-06-01 10:15:55 +03:00
|
|
|
$row['number'] = $row['transaction_number'];
|
2020-01-20 22:58:49 +03:00
|
|
|
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
$rules = (new Request())->rules();
|
|
|
|
|
|
|
|
$rules['invoice_number'] = 'required|string';
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
}
|