2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
namespace App\Exports\Purchases;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
use App\Abstracts\Export;
|
2019-11-16 10:21:14 +03:00
|
|
|
use App\Models\Banking\Transaction as Model;
|
2021-02-15 22:58:58 +03:00
|
|
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2021-02-15 22:58:58 +03:00
|
|
|
class Payments extends Export implements WithColumnFormatting
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
2020-06-07 12:11:37 +03:00
|
|
|
$model = Model::with('account', 'bill', 'category', 'contact')->expense()->usingSearchString(request('search'));
|
2019-11-16 10:21:14 +03:00
|
|
|
|
|
|
|
if (!empty($this->ids)) {
|
|
|
|
$model->whereIn('id', (array) $this->ids);
|
|
|
|
}
|
|
|
|
|
2020-03-02 23:13:36 +03:00
|
|
|
return $model->cursor();
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
|
2020-01-21 00:04:10 +03:00
|
|
|
public function map($model): array
|
|
|
|
{
|
|
|
|
$model->account_name = $model->account->name;
|
2020-12-24 01:28:38 +03:00
|
|
|
$model->bill_number = $model->bill->document_number ?? 0;
|
2020-01-21 00:04:10 +03:00
|
|
|
$model->contact_email = $model->contact->email;
|
|
|
|
$model->category_name = $model->category->name;
|
|
|
|
|
|
|
|
return parent::map($model);
|
|
|
|
}
|
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
public function fields(): array
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'paid_at',
|
|
|
|
'amount',
|
|
|
|
'currency_code',
|
|
|
|
'currency_rate',
|
2020-01-21 00:04:10 +03:00
|
|
|
'account_name',
|
|
|
|
'bill_number',
|
|
|
|
'contact_email',
|
|
|
|
'category_name',
|
2020-01-20 00:21:37 +03:00
|
|
|
'description',
|
2019-11-16 10:21:14 +03:00
|
|
|
'payment_method',
|
2020-01-20 00:21:37 +03:00
|
|
|
'reference',
|
2019-11-16 10:21:14 +03:00
|
|
|
'reconciled',
|
|
|
|
];
|
|
|
|
}
|
2021-02-15 22:58:58 +03:00
|
|
|
|
|
|
|
public function columnFormats(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'A' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
|
|
|
];
|
|
|
|
}
|
2020-01-20 00:21:37 +03:00
|
|
|
}
|