v2 first commit
This commit is contained in:
68
app/Exports/Incomes/Customers.php
Normal file
68
app/Exports/Incomes/Customers.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes;
|
||||
|
||||
use App\Models\Common\Contact as Model;
|
||||
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 Customers implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $ids;
|
||||
|
||||
public function __construct($ids = null)
|
||||
{
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::type('customer')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->name,
|
||||
$model->email,
|
||||
$model->user_id,
|
||||
$model->tax_number,
|
||||
$model->phone,
|
||||
$model->address,
|
||||
$model->website,
|
||||
$model->currency_code,
|
||||
$model->reference,
|
||||
$model->enabled,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'name',
|
||||
'email',
|
||||
'user_id',
|
||||
'tax_number',
|
||||
'phone',
|
||||
'address',
|
||||
'website',
|
||||
'currency_code',
|
||||
'reference',
|
||||
'enabled',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'customers';
|
||||
}
|
||||
}
|
||||
33
app/Exports/Incomes/Invoices.php
Normal file
33
app/Exports/Incomes/Invoices.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes;
|
||||
|
||||
use App\Exports\Incomes\Sheets\Invoices as Base;
|
||||
use App\Exports\Incomes\Sheets\InvoiceItems;
|
||||
use App\Exports\Incomes\Sheets\InvoiceItemTaxes;
|
||||
use App\Exports\Incomes\Sheets\InvoiceHistories;
|
||||
use App\Exports\Incomes\Sheets\InvoicePayments;
|
||||
use App\Exports\Incomes\Sheets\InvoiceTotals;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class Invoices implements WithMultipleSheets
|
||||
{
|
||||
public $ids;
|
||||
|
||||
public function __construct($ids = null)
|
||||
{
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
'invoices' => new Base($this->ids),
|
||||
'invoice_items' => new InvoiceItems($this->ids),
|
||||
'invoice_item_taxes' => new InvoiceItemTaxes($this->ids),
|
||||
'invoice_histories' => new InvoiceHistories($this->ids),
|
||||
'invoice_payments' => new InvoicePayments($this->ids),
|
||||
'invoice_totals' => new InvoiceTotals($this->ids),
|
||||
];
|
||||
}
|
||||
}
|
||||
66
app/Exports/Incomes/Revenues.php
Normal file
66
app/Exports/Incomes/Revenues.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes;
|
||||
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
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 Revenues implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $ids;
|
||||
|
||||
public function __construct($ids = null)
|
||||
{
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::type('income')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->account_id,
|
||||
$model->paid_at,
|
||||
$model->amount,
|
||||
$model->currency_code,
|
||||
$model->currency_rate,
|
||||
$model->document_id,
|
||||
$model->contact_id,
|
||||
$model->payment_method,
|
||||
$model->reconciled,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'account_id',
|
||||
'paid_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'document_id',
|
||||
'contact_id',
|
||||
'payment_method',
|
||||
'reconciled',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'revenues';
|
||||
}
|
||||
}
|
||||
56
app/Exports/Incomes/Sheets/InvoiceHistories.php
Normal file
56
app/Exports/Incomes/Sheets/InvoiceHistories.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Income\InvoiceHistory as Model;
|
||||
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 InvoiceHistories implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $invoice_ids;
|
||||
|
||||
public function __construct($invoice_ids = null)
|
||||
{
|
||||
$this->invoice_ids = $invoice_ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->invoice_ids)) {
|
||||
$model->whereIn('invoice_id', (array) $this->invoice_ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->invoice_id,
|
||||
$model->status_code,
|
||||
$model->notify,
|
||||
$model->description,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'invoice_id',
|
||||
'status_code',
|
||||
'notify',
|
||||
'description',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoice_histories';
|
||||
}
|
||||
}
|
||||
58
app/Exports/Incomes/Sheets/InvoiceItemTaxes.php
Normal file
58
app/Exports/Incomes/Sheets/InvoiceItemTaxes.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Income\InvoiceItemTax as Model;
|
||||
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 InvoiceItemTaxes implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $invoice_ids;
|
||||
|
||||
public function __construct($invoice_ids = null)
|
||||
{
|
||||
$this->invoice_ids = $invoice_ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->invoice_ids)) {
|
||||
$model->whereIn('invoice_id', (array) $this->invoice_ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->invoice_id,
|
||||
$model->invoice_item_id,
|
||||
$model->tax_id,
|
||||
$model->name,
|
||||
$model->amount,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'invoice_id',
|
||||
'invoice_item_id',
|
||||
'tax_id',
|
||||
'name',
|
||||
'amount',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoice_item_taxes';
|
||||
}
|
||||
}
|
||||
60
app/Exports/Incomes/Sheets/InvoiceItems.php
Normal file
60
app/Exports/Incomes/Sheets/InvoiceItems.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Income\InvoiceItem as Model;
|
||||
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 InvoiceItems implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $invoice_ids;
|
||||
|
||||
public function __construct($invoice_ids = null)
|
||||
{
|
||||
$this->invoice_ids = $invoice_ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->invoice_ids)) {
|
||||
$model->whereIn('invoice_id', (array) $this->invoice_ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->invoice_id,
|
||||
$model->item_id,
|
||||
$model->name,
|
||||
$model->price,
|
||||
$model->total,
|
||||
$model->tax,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'invoice_id',
|
||||
'item_id',
|
||||
'name',
|
||||
'price',
|
||||
'total',
|
||||
'tax',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoice_items';
|
||||
}
|
||||
}
|
||||
66
app/Exports/Incomes/Sheets/InvoicePayments.php
Normal file
66
app/Exports/Incomes/Sheets/InvoicePayments.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
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 InvoicePayments implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
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('invoice_id', (array) $this->invoice_ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->account_id,
|
||||
$model->paid_at,
|
||||
$model->amount,
|
||||
$model->currency_code,
|
||||
$model->currency_rate,
|
||||
$model->document_id,
|
||||
$model->contact_id,
|
||||
$model->payment_method,
|
||||
$model->reconciled,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'account_id',
|
||||
'paid_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'document_id',
|
||||
'contact_id',
|
||||
'payment_method',
|
||||
'reconciled',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoice_payments';
|
||||
}
|
||||
}
|
||||
58
app/Exports/Incomes/Sheets/InvoiceTotals.php
Normal file
58
app/Exports/Incomes/Sheets/InvoiceTotals.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Income\InvoiceTotal as Model;
|
||||
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 InvoiceTotals implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $invoice_ids;
|
||||
|
||||
public function __construct($invoice_ids = null)
|
||||
{
|
||||
$this->invoice_ids = $invoice_ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->invoice_ids)) {
|
||||
$model->whereIn('invoice_id', (array) $this->invoice_ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->invoice_id,
|
||||
$model->code,
|
||||
$model->name,
|
||||
$model->amount,
|
||||
$model->sort_order,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'invoice_id',
|
||||
'code',
|
||||
'name',
|
||||
'amount',
|
||||
'sort_order',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoice_totals';
|
||||
}
|
||||
}
|
||||
81
app/Exports/Incomes/Sheets/Invoices.php
Normal file
81
app/Exports/Incomes/Sheets/Invoices.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Incomes\Sheets;
|
||||
|
||||
use App\Models\Income\Invoice as Model;
|
||||
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 Invoices implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
|
||||
{
|
||||
public $ids;
|
||||
|
||||
public function __construct($ids = null)
|
||||
{
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
return [
|
||||
$model->invoice_number,
|
||||
$model->order_number,
|
||||
$model->invoice_status_code,
|
||||
$model->invoiced_at,
|
||||
$model->due_at,
|
||||
$model->amount,
|
||||
$model->currency_code,
|
||||
$model->currency_rate,
|
||||
$model->contact_id,
|
||||
$model->contact_name,
|
||||
$model->contact_email,
|
||||
$model->contact_tax_number,
|
||||
$model->contact_phone,
|
||||
$model->contact_address,
|
||||
$model->notes,
|
||||
$model->category_id,
|
||||
$model->footer,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'invoice_number',
|
||||
'order_number',
|
||||
'invoice_status_code',
|
||||
'invoiced_at',
|
||||
'due_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'contact_id',
|
||||
'contact_name',
|
||||
'contact_email',
|
||||
'contact_tax_number',
|
||||
'contact_address',
|
||||
'notes',
|
||||
'category_id',
|
||||
'footer',
|
||||
];
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'invoices';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user