added code and description fields to category import and export models
This commit is contained in:
parent
09574e0335
commit
3a94319805
|
|
@ -25,9 +25,11 @@ class Categories extends Export
|
||||||
public function fields(): array
|
public function fields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'code',
|
||||||
'name',
|
'name',
|
||||||
'type',
|
'type',
|
||||||
'color',
|
'color',
|
||||||
|
'description',
|
||||||
'parent_name',
|
'parent_name',
|
||||||
'enabled',
|
'enabled',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Imports\Purchases\Bills\Sheets;
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
use App\Http\Requests\Banking\Transaction as Request;
|
use App\Http\Requests\Banking\Transaction as Request;
|
||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
use App\Models\Setting\Category;
|
||||||
|
|
||||||
class BillTransactions extends Import
|
class BillTransactions extends Import
|
||||||
{
|
{
|
||||||
|
|
@ -36,9 +37,9 @@ class BillTransactions extends Import
|
||||||
|
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
$row['type'] = 'expense';
|
$row['type'] = Model::EXPENSE_TYPE;
|
||||||
$row['account_id'] = $this->getAccountId($row);
|
$row['account_id'] = $this->getAccountId($row);
|
||||||
$row['category_id'] = $this->getCategoryId($row, 'expense');
|
$row['category_id'] = $this->getCategoryId($row, Category::EXPENSE_TYPE);
|
||||||
$row['contact_id'] = $this->getContactId($row, 'vendor');
|
$row['contact_id'] = $this->getContactId($row, 'vendor');
|
||||||
$row['currency_code'] = $this->getCurrencyCode($row);
|
$row['currency_code'] = $this->getCurrencyCode($row);
|
||||||
$row['document_id'] = $this->getDocumentId($row);
|
$row['document_id'] = $this->getDocumentId($row);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Imports\Sales\Invoices\Sheets;
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
use App\Http\Requests\Banking\Transaction as Request;
|
use App\Http\Requests\Banking\Transaction as Request;
|
||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
use App\Models\Setting\Category;
|
||||||
|
|
||||||
class InvoiceTransactions extends Import
|
class InvoiceTransactions extends Import
|
||||||
{
|
{
|
||||||
|
|
@ -37,10 +38,10 @@ class InvoiceTransactions extends Import
|
||||||
|
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
$row['type'] = 'income';
|
$row['type'] = Model::INCOME_TYPE;
|
||||||
$row['currency_code'] = $this->getCurrencyCode($row);
|
$row['currency_code'] = $this->getCurrencyCode($row);
|
||||||
$row['account_id'] = $this->getAccountId($row);
|
$row['account_id'] = $this->getAccountId($row);
|
||||||
$row['category_id'] = $this->getCategoryId($row, 'income');
|
$row['category_id'] = $this->getCategoryId($row, Category::INCOME_TYPE);
|
||||||
$row['contact_id'] = $this->getContactId($row, 'customer');
|
$row['contact_id'] = $this->getContactId($row, 'customer');
|
||||||
$row['document_id'] = $this->getDocumentId($row);
|
$row['document_id'] = $this->getDocumentId($row);
|
||||||
$row['number'] = $row['transaction_number'];
|
$row['number'] = $row['transaction_number'];
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ class Categories extends Import
|
||||||
public $columns = [
|
public $columns = [
|
||||||
'name',
|
'name',
|
||||||
'type',
|
'type',
|
||||||
|
'code',
|
||||||
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function model(array $row)
|
public function model(array $row)
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ trait Import
|
||||||
{
|
{
|
||||||
$id = isset($row['category_id']) ? $row['category_id'] : null;
|
$id = isset($row['category_id']) ? $row['category_id'] : null;
|
||||||
|
|
||||||
$type = !empty($type) ? $type : (!empty($row['type']) ? $row['type'] : 'income');
|
$type = !empty($type) ? $type : (!empty($row['type']) ? $row['type'] : Category::INCOME_TYPE);
|
||||||
|
|
||||||
if (empty($id) && !empty($row['category_name'])) {
|
if (empty($id) && !empty($row['category_name'])) {
|
||||||
$id = $this->getCategoryIdFromName($row, $type);
|
$id = $this->getCategoryIdFromName($row, $type);
|
||||||
|
|
@ -96,14 +96,14 @@ trait Import
|
||||||
|
|
||||||
public function getCategoryType($type)
|
public function getCategoryType($type)
|
||||||
{
|
{
|
||||||
return array_key_exists($type, config('type.category')) ? $type : 'other';
|
return array_key_exists($type, config('type.category')) ? $type : Category::OTHER_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContactId($row, $type = null)
|
public function getContactId($row, $type = null)
|
||||||
{
|
{
|
||||||
$id = isset($row['contact_id']) ? $row['contact_id'] : null;
|
$id = isset($row['contact_id']) ? $row['contact_id'] : null;
|
||||||
|
|
||||||
$type = !empty($type) ? $type : (!empty($row['type']) ? (($row['type'] == 'income') ? 'customer' : 'vendor') : 'customer');
|
$type = !empty($type) ? $type : (!empty($row['type']) ? (($row['type'] == Transaction::INCOME_TYPE) ? 'customer' : 'vendor') : 'customer');
|
||||||
|
|
||||||
if (empty($row['contact_id']) && !empty($row['contact_email'])) {
|
if (empty($row['contact_id']) && !empty($row['contact_email'])) {
|
||||||
$id = $this->getContactIdFromEmail($row, $type);
|
$id = $this->getContactIdFromEmail($row, $type);
|
||||||
|
|
@ -180,7 +180,7 @@ trait Import
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($id) && !empty($row['invoice_bill_number'])) {
|
if (empty($id) && !empty($row['invoice_bill_number'])) {
|
||||||
if ($row['type'] == 'income') {
|
if ($row['type'] == Transaction::INCOME_TYPE) {
|
||||||
$id = Document::invoice()->number($row['invoice_bill_number'])->pluck('id')->first();
|
$id = Document::invoice()->number($row['invoice_bill_number'])->pluck('id')->first();
|
||||||
} else {
|
} else {
|
||||||
$id = Document::bill()->number($row['invoice_bill_number'])->pluck('id')->first();
|
$id = Document::bill()->number($row['invoice_bill_number'])->pluck('id')->first();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue