akaunting/app/Imports/Purchases/Sheets/BillTransactions.php

38 lines
855 B
PHP
Raw Normal View History

2020-01-20 01:26:35 +03:00
<?php
namespace App\Imports\Purchases\Sheets;
use App\Abstracts\Import;
use App\Models\Banking\Transaction as Model;
use App\Http\Requests\Banking\Transaction as Request;
class BillTransactions extends Import
{
public function model(array $row)
{
return new Model($row);
}
public function map($row): array
{
2020-01-20 11:12:14 +03:00
$row = parent::map($row);
2020-01-20 01:26:35 +03:00
2020-01-20 11:12:14 +03:00
$row['type'] = 'expense';
2020-01-21 09:55:12 +03:00
$row['account_id'] = $this->getAccountId($row);
$row['category_id'] = $this->getCategoryId($row, 'expense');
$row['contact_id'] = $this->getContactId($row, 'vendor');
$row['document_id'] = $this->getDocumentId($row);
2020-01-20 01:26:35 +03:00
return $row;
}
public function rules(): array
{
2020-01-21 09:55:12 +03:00
$rules = (new Request())->rules();
$rules['bill_number'] = 'required|string';
return $rules;
2020-01-20 01:26:35 +03:00
}
}