export abstract

This commit is contained in:
denisdulici
2020-01-20 02:05:40 +03:00
parent 88dade86b6
commit 569f6c314f
19 changed files with 129 additions and 628 deletions

View File

@ -2,53 +2,23 @@
namespace App\Exports\Sales\Sheets;
use App\Abstracts\Export;
use App\Models\Banking\Transaction as Model;
use Jenssegers\Date\Date;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithTitle;
class InvoiceTransactions implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
class InvoiceTransactions extends Export
{
public $invoice_ids;
public function __construct($invoice_ids = null)
{
$this->invoice_ids = $invoice_ids;
}
public function collection()
{
$model = Model::type('income')->isDocument()->usingSearchString(request('search'));
if (!empty($this->invoice_ids)) {
$model->whereIn('document_id', (array) $this->invoice_ids);
if (!empty($this->ids)) {
$model->whereIn('document_id', (array) $this->ids);
}
return $model->get();
}
public function map($model): array
{
return [
Date::parse($model->paid_at)->format('Y-m-d'),
$model->amount,
$model->currency_code,
$model->currency_rate,
$model->account_id,
$model->document_id,
$model->contact_id,
$model->category_id,
$model->description,
$model->payment_method,
$model->reference,
$model->reconciled,
];
}
public function headings(): array
public function fields(): array
{
return [
'paid_at',
@ -65,9 +35,4 @@ class InvoiceTransactions implements FromCollection, ShouldAutoSize, WithHeading
'reconciled',
];
}
public function title(): string
{
return 'invoice_transactions';
}
}