added import and export recurring transactions
This commit is contained in:
18
app/Imports/Banking/RecurringTransactions.php
Normal file
18
app/Imports/Banking/RecurringTransactions.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Banking;
|
||||
|
||||
use App\Abstracts\ImportMultipleSheets;
|
||||
use App\Imports\Banking\Sheets\Recurring;
|
||||
use App\Imports\Banking\Sheets\RecurringTransactions as Base;
|
||||
|
||||
class RecurringTransactions extends ImportMultipleSheets
|
||||
{
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
'recurring_transactions' => new Base(),
|
||||
'recurring' => new Recurring(),
|
||||
];
|
||||
}
|
||||
}
|
24
app/Imports/Banking/Sheets/Recurring.php
Normal file
24
app/Imports/Banking/Sheets/Recurring.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Banking\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Common\Recurring as Model;
|
||||
|
||||
class Recurring extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row = parent::map($row);
|
||||
|
||||
$row['recurable_id'] = (int) Transaction::isRecurring()->number($row['transaction_number'])->pluck('id')->first();
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
38
app/Imports/Banking/Sheets/RecurringTransactions.php
Normal file
38
app/Imports/Banking/Sheets/RecurringTransactions.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Banking\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
|
||||
class RecurringTransactions extends Import
|
||||
{
|
||||
public $request_class = Request::class;
|
||||
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row = parent::map($row);
|
||||
|
||||
$transaction_type = str_replace('-recurring', '', $row['type']);
|
||||
|
||||
$row['currency_code'] = $this->getCurrencyCode($row);
|
||||
$row['account_id'] = $this->getAccountId($row);
|
||||
$row['category_id'] = $this->getCategoryId($row, $transaction_type);
|
||||
$row['contact_id'] = $this->getContactId($row, $transaction_type);
|
||||
|
||||
if ($transaction_type == 'income') {
|
||||
$row['document_id'] = Document::invoiceRecurring()->number($row['invoice_bill_number'])->pluck('id')->first();
|
||||
} else {
|
||||
$row['document_id'] = Document::billRecurring()->number($row['invoice_bill_number'])->pluck('id')->first();
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user