Seperate Document Import/Export files into Invoice/Bill
This commit is contained in:
43
app/Exports/Purchases/Sheets/BillHistories.php
Normal file
43
app/Exports/Purchases/Sheets/BillHistories.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Document\DocumentHistory as Model;
|
||||
|
||||
class BillHistories extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$document = $model->document;
|
||||
|
||||
if (empty($document)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$model->bill_number = $document->document_number;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'status',
|
||||
'notify',
|
||||
'description',
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Exports/Purchases/Sheets/BillItemTaxes.php
Normal file
45
app/Exports/Purchases/Sheets/BillItemTaxes.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Document\DocumentItemTax as Model;
|
||||
|
||||
class BillItemTaxes extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document', 'item', 'tax')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$document = $model->document;
|
||||
|
||||
if (empty($document)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$model->bill_number = $document->document_number;
|
||||
$model->item_name = $model->item->name;
|
||||
$model->tax_rate = $model->tax->rate;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'item_name',
|
||||
'tax_rate',
|
||||
'amount',
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Exports/Purchases/Sheets/BillItems.php
Normal file
46
app/Exports/Purchases/Sheets/BillItems.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Document\DocumentItem as Model;
|
||||
|
||||
class BillItems extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document', 'item')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$document = $model->document;
|
||||
|
||||
if (empty($document)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$model->bill_number = $document->document_number;
|
||||
$model->item_name = $model->item->name;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'item_name',
|
||||
'quantity',
|
||||
'price',
|
||||
'total',
|
||||
'tax',
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Exports/Purchases/Sheets/BillTotals.php
Normal file
44
app/Exports/Purchases/Sheets/BillTotals.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Document\DocumentTotal as Model;
|
||||
|
||||
class BillTotals extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$document = $model->document;
|
||||
|
||||
if (empty($document)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$model->bill_number = $document->document_number;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'code',
|
||||
'name',
|
||||
'amount',
|
||||
'sort_order',
|
||||
];
|
||||
}
|
||||
}
|
||||
63
app/Exports/Purchases/Sheets/BillTransactions.php
Normal file
63
app/Exports/Purchases/Sheets/BillTransactions.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class BillTransactions extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'category', 'contact', 'document')->bill()->isDocument()->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$document = $model->document;
|
||||
|
||||
if (empty($document)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$model->bill_number = $document->document_number;
|
||||
$model->account_name = $model->account->name;
|
||||
$model->category_name = $model->category->name;
|
||||
$model->contact_email = $model->contact->email;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'paid_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'account_name',
|
||||
'contact_email',
|
||||
'category_name',
|
||||
'description',
|
||||
'payment_method',
|
||||
'reference',
|
||||
'reconciled',
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'B' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
||||
];
|
||||
}
|
||||
}
|
||||
59
app/Exports/Purchases/Sheets/Bills.php
Normal file
59
app/Exports/Purchases/Sheets/Bills.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Purchases\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Document\Document as Model;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class Bills extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('category')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$model->category_name = $model->category->name;
|
||||
$model->bill_number = $model->document_number;
|
||||
$model->billed_at = $model->issued_at;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'bill_number',
|
||||
'order_number',
|
||||
'status',
|
||||
'billed_at',
|
||||
'due_at',
|
||||
'amount',
|
||||
'currency_code',
|
||||
'currency_rate',
|
||||
'category_name',
|
||||
'contact_name',
|
||||
'contact_email',
|
||||
'contact_tax_number',
|
||||
'contact_phone',
|
||||
'contact_address',
|
||||
'notes',
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
||||
'E' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user