added import and export recurring transactions
This commit is contained in:
28
app/Exports/Banking/RecurringTransactions.php
Normal file
28
app/Exports/Banking/RecurringTransactions.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Banking;
|
||||
|
||||
use App\Exports\Banking\Sheets\Recurring;
|
||||
use App\Exports\Banking\Sheets\RecurringTransactions as Base;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class RecurringTransactions implements WithMultipleSheets
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
public $ids;
|
||||
|
||||
public function __construct($ids = null)
|
||||
{
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
new Recurring($this->ids),
|
||||
new Base($this->ids),
|
||||
];
|
||||
}
|
||||
}
|
36
app/Exports/Banking/Sheets/Recurring.php
Normal file
36
app/Exports/Banking/Sheets/Recurring.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Banking\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Common\Recurring as Model;
|
||||
|
||||
class Recurring extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
return Model::transaction()->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$model->transaction_number = $model->recurable->number;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'recurable_type',
|
||||
'transaction_number',
|
||||
'frequency',
|
||||
'interval',
|
||||
'started_at',
|
||||
'status',
|
||||
'limit_by',
|
||||
'limit_count',
|
||||
'auto_send',
|
||||
];
|
||||
}
|
||||
}
|
53
app/Exports/Banking/Sheets/RecurringTransactions.php
Normal file
53
app/Exports/Banking/Sheets/RecurringTransactions.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Banking\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class RecurringTransactions extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
return Model::with('account', 'category', 'contact', 'document')->isRecurring()->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$model->account_name = $model->account->name;
|
||||
$model->contact_email = $model->contact->email;
|
||||
$model->category_name = $model->category->name;
|
||||
$model->invoice_bill_number = $model->document->document_number ?? 0;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'type',
|
||||
'number',
|
||||
'paid_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'account_name',
|
||||
'invoice_bill_number',
|
||||
'contact_email',
|
||||
'category_name',
|
||||
'description',
|
||||
'payment_method',
|
||||
'reference',
|
||||
'reconciled',
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'C' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user