Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added import and export recurring bills
- Loading branch information
1 parent
09baf19
commit 0bbbe25
Showing
31 changed files
with
685 additions
and
29 deletions.
There are no files selected for viewing
14 changes: 7 additions & 7 deletions
14
app/Exports/Purchases/Bills.php → app/Exports/Purchases/Bills/Bills.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...xports/Purchases/Sheets/BillHistories.php → .../Purchases/Bills/Sheets/BillHistories.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...xports/Purchases/Sheets/BillItemTaxes.php → .../Purchases/Bills/Sheets/BillItemTaxes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/Exports/Purchases/Sheets/BillItems.php → ...orts/Purchases/Bills/Sheets/BillItems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/Exports/Purchases/Sheets/BillTotals.php → ...rts/Purchases/Bills/Sheets/BillTotals.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rts/Purchases/Sheets/BillTransactions.php → ...rchases/Bills/Sheets/BillTransactions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/Exports/Purchases/Sheets/Bills.php → app/Exports/Purchases/Bills/Sheets/Bills.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills; | ||
|
||
use App\Exports\Purchases\RecurringBills\Sheets\Recurring; | ||
use App\Exports\Purchases\RecurringBills\Sheets\RecurringBills as Base; | ||
use App\Exports\Purchases\RecurringBills\Sheets\RecurringBillItems; | ||
use App\Exports\Purchases\RecurringBills\Sheets\RecurringBillItemTaxes; | ||
use App\Exports\Purchases\RecurringBills\Sheets\RecurringBillHistories; | ||
use App\Exports\Purchases\RecurringBills\Sheets\RecurringBillTotals; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\WithMultipleSheets; | ||
|
||
class RecurringBills 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), | ||
new RecurringBillItems($this->ids), | ||
new RecurringBillItemTaxes($this->ids), | ||
new RecurringBillHistories($this->ids), | ||
new RecurringBillTotals($this->ids), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Common\Recurring as Model; | ||
|
||
class Recurring extends Export | ||
{ | ||
public function collection() | ||
{ | ||
return Model::bill()->cursor(); | ||
} | ||
|
||
public function map($model): array | ||
{ | ||
$model->bill_number = $model->recurable->document_number; | ||
|
||
return parent::map($model); | ||
} | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
'recurable_type', | ||
'bill_number', | ||
'frequency', | ||
'interval', | ||
'started_at', | ||
'status', | ||
'limit_by', | ||
'limit_count', | ||
'auto_send', | ||
]; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/Exports/Purchases/RecurringBills/Sheets/RecurringBillHistories.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Document\DocumentHistory as Model; | ||
|
||
class RecurringBillHistories extends Export | ||
{ | ||
public function collection() | ||
{ | ||
return Model::with('document')->billRecurring()->collectForExport($this->ids, null, 'document_id'); | ||
} | ||
|
||
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', | ||
]; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/Exports/Purchases/RecurringBills/Sheets/RecurringBillItemTaxes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Document\DocumentItemTax as Model; | ||
|
||
class RecurringBillItemTaxes extends Export | ||
{ | ||
public function collection() | ||
{ | ||
return Model::with('document', 'item', 'tax')->billRecurring()->collectForExport($this->ids, null, 'document_id'); | ||
} | ||
|
||
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', | ||
]; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/Exports/Purchases/RecurringBills/Sheets/RecurringBillItems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Document\DocumentItem as Model; | ||
|
||
class RecurringBillItems extends Export | ||
{ | ||
public function collection() | ||
{ | ||
return Model::with('document', 'item')->billRecurring()->collectForExport($this->ids, null, 'document_id'); | ||
} | ||
|
||
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->item_description = $model->item->description; | ||
$model->item_type = $model->item->type; | ||
|
||
return parent::map($model); | ||
} | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
'bill_number', | ||
'item_name', | ||
'item_description', | ||
'item_type', | ||
'quantity', | ||
'price', | ||
'total', | ||
'tax', | ||
]; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/Exports/Purchases/RecurringBills/Sheets/RecurringBillTotals.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Document\DocumentTotal as Model; | ||
|
||
class RecurringBillTotals extends Export | ||
{ | ||
public function collection() | ||
{ | ||
return Model::with('document')->billRecurring()->collectForExport($this->ids, null, 'document_id'); | ||
} | ||
|
||
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', | ||
]; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/Exports/Purchases/RecurringBills/Sheets/RecurringBills.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Exports\Purchases\RecurringBills\Sheets; | ||
|
||
use App\Abstracts\Export; | ||
use App\Models\Document\Document as Model; | ||
use Maatwebsite\Excel\Concerns\WithColumnFormatting; | ||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; | ||
|
||
class RecurringBills extends Export implements WithColumnFormatting | ||
{ | ||
public function collection() | ||
{ | ||
return Model::with('category')->billRecurring()->collectForExport($this->ids, ['document_number' => 'desc']); | ||
} | ||
|
||
public function map($model): array | ||
{ | ||
$country = null; | ||
|
||
if ($model->contact_country && array_key_exists($model->contact_country, trans('countries'))) { | ||
$country = trans('countries.' . $model->contact_country); | ||
} | ||
|
||
$model->category_name = $model->category->name; | ||
$model->bill_number = $model->document_number; | ||
$model->billed_at = $model->issued_at; | ||
$model->contact_country = $country; | ||
|
||
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', | ||
'contact_country', | ||
'contact_state', | ||
'contact_zip_code', | ||
'contact_city', | ||
'notes', | ||
]; | ||
} | ||
|
||
public function columnFormats(): array | ||
{ | ||
return [ | ||
'D' => NumberFormat::FORMAT_DATE_YYYYMMDD, | ||
'E' => NumberFormat::FORMAT_DATE_YYYYMMDD, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.