renamed income/expense
This commit is contained in:
		
							
								
								
									
										33
									
								
								app/Exports/Purchases/Bills.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/Exports/Purchases/Bills.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases; | ||||
|  | ||||
| use App\Exports\Purchases\Sheets\Bills as Base; | ||||
| use App\Exports\Purchases\Sheets\BillItems; | ||||
| use App\Exports\Purchases\Sheets\BillItemTaxes; | ||||
| use App\Exports\Purchases\Sheets\BillHistories; | ||||
| use App\Exports\Purchases\Sheets\BillPayments; | ||||
| use App\Exports\Purchases\Sheets\BillTotals; | ||||
| use Maatwebsite\Excel\Concerns\WithMultipleSheets; | ||||
|  | ||||
| class Bills implements WithMultipleSheets | ||||
| { | ||||
|     public $ids; | ||||
|  | ||||
|     public function __construct($ids = null) | ||||
|     { | ||||
|         $this->ids = $ids; | ||||
|     } | ||||
|  | ||||
|     public function sheets(): array | ||||
|     { | ||||
|         return [ | ||||
|             'bills' => new Base($this->ids), | ||||
|             'bill_items' => new BillItems($this->ids), | ||||
|             'bill_item_taxes' => new BillItemTaxes($this->ids), | ||||
|             'bill_histories' => new BillHistories($this->ids), | ||||
|             'bill_payments' => new BillPayments($this->ids), | ||||
|             'bill_totals' => new BillTotals($this->ids), | ||||
|         ]; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										66
									
								
								app/Exports/Purchases/Payments.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								app/Exports/Purchases/Payments.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases; | ||||
|  | ||||
| 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 Payments implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $ids; | ||||
|  | ||||
|     public function __construct($ids = null) | ||||
|     { | ||||
|         $this->ids = $ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::type('expense')->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 'payments'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										56
									
								
								app/Exports/Purchases/Sheets/BillHistories.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								app/Exports/Purchases/Sheets/BillHistories.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\Sheets; | ||||
|  | ||||
| use App\Models\Purchase\BillHistory 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 BillHistories implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $bill_ids; | ||||
|  | ||||
|     public function __construct($bill_ids = null) | ||||
|     { | ||||
|         $this->bill_ids = $bill_ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::usingSearchString(request('search')); | ||||
|  | ||||
|         if (!empty($this->bill_ids)) { | ||||
|             $model->whereIn('bill_id', (array) $this->bill_ids); | ||||
|         } | ||||
|  | ||||
|         return $model->get(); | ||||
|     } | ||||
|  | ||||
|     public function map($model): array | ||||
|     { | ||||
|         return [ | ||||
|             $model->bill_id, | ||||
|             $model->status_code, | ||||
|             $model->notify, | ||||
|             $model->description, | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function headings(): array | ||||
|     { | ||||
|         return [ | ||||
|             'bill_id', | ||||
|             'status_code', | ||||
|             'notify', | ||||
|             'description', | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function title(): string | ||||
|     { | ||||
|         return 'bill_histories'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										58
									
								
								app/Exports/Purchases/Sheets/BillItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Exports/Purchases/Sheets/BillItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\Sheets; | ||||
|  | ||||
| use App\Models\Purchase\BillItemTax 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 BillItemTaxes implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $bill_ids; | ||||
|  | ||||
|     public function __construct($bill_ids = null) | ||||
|     { | ||||
|         $this->bill_ids = $bill_ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::usingSearchString(request('search')); | ||||
|  | ||||
|         if (!empty($this->bill_ids)) { | ||||
|             $model->whereIn('bill_id', (array) $this->bill_ids); | ||||
|         } | ||||
|  | ||||
|         return $model->get(); | ||||
|     } | ||||
|  | ||||
|     public function map($model): array | ||||
|     { | ||||
|         return [ | ||||
|             $model->bill_id, | ||||
|             $model->bill_item_id, | ||||
|             $model->tax_id, | ||||
|             $model->name, | ||||
|             $model->amount, | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function headings(): array | ||||
|     { | ||||
|         return [ | ||||
|             'bill_id', | ||||
|             'bill_item_id', | ||||
|             'tax_id', | ||||
|             'name', | ||||
|             'amount', | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function title(): string | ||||
|     { | ||||
|         return 'bill_item_taxes'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										60
									
								
								app/Exports/Purchases/Sheets/BillItems.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								app/Exports/Purchases/Sheets/BillItems.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\Sheets; | ||||
|  | ||||
| use App\Models\Purchase\BillItem 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 BillItems implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $bill_ids; | ||||
|  | ||||
|     public function __construct($bill_ids = null) | ||||
|     { | ||||
|         $this->bill_ids = $bill_ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::usingSearchString(request('search')); | ||||
|  | ||||
|         if (!empty($this->bill_ids)) { | ||||
|             $model->whereIn('bill_id', (array) $this->bill_ids); | ||||
|         } | ||||
|  | ||||
|         return $model->get(); | ||||
|     } | ||||
|  | ||||
|     public function map($model): array | ||||
|     { | ||||
|         return [ | ||||
|             $model->bill_id, | ||||
|             $model->item_id, | ||||
|             $model->name, | ||||
|             $model->price, | ||||
|             $model->total, | ||||
|             $model->tax, | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function headings(): array | ||||
|     { | ||||
|         return [ | ||||
|             'bill_id', | ||||
|             'item_id', | ||||
|             'name', | ||||
|             'price', | ||||
|             'total', | ||||
|             'tax', | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function title(): string | ||||
|     { | ||||
|         return 'bill_items'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										66
									
								
								app/Exports/Purchases/Sheets/BillPayments.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								app/Exports/Purchases/Sheets/BillPayments.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\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 BillPayments implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $bill_ids; | ||||
|  | ||||
|     public function __construct($bill_ids = null) | ||||
|     { | ||||
|         $this->bill_ids = $bill_ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::type('expense')->isDocument()->usingSearchString(request('search')); | ||||
|  | ||||
|         if (!empty($this->bill_ids)) { | ||||
|             $model->whereIn('bill_id', (array) $this->bill_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 'bill_payments'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										58
									
								
								app/Exports/Purchases/Sheets/BillTotals.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Exports/Purchases/Sheets/BillTotals.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\Sheets; | ||||
|  | ||||
| use App\Models\Purchase\BillTotal 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 BillTotals implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $bill_ids; | ||||
|  | ||||
|     public function __construct($bill_ids = null) | ||||
|     { | ||||
|         $this->bill_ids = $bill_ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::usingSearchString(request('search')); | ||||
|  | ||||
|         if (!empty($this->bill_ids)) { | ||||
|             $model->whereIn('bill_id', (array) $this->bill_ids); | ||||
|         } | ||||
|  | ||||
|         return $model->get(); | ||||
|     } | ||||
|  | ||||
|     public function map($model): array | ||||
|     { | ||||
|         return [ | ||||
|             $model->bill_id, | ||||
|             $model->code, | ||||
|             $model->name, | ||||
|             $model->amount, | ||||
|             $model->sort_order, | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function headings(): array | ||||
|     { | ||||
|         return [ | ||||
|             'bill_id', | ||||
|             'code', | ||||
|             'name', | ||||
|             'amount', | ||||
|             'sort_order', | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function title(): string | ||||
|     { | ||||
|         return 'bill_totals'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										81
									
								
								app/Exports/Purchases/Sheets/Bills.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								app/Exports/Purchases/Sheets/Bills.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases\Sheets; | ||||
|  | ||||
| use App\Models\Purchase\Bill 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 Bills 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->bill_number, | ||||
|             $model->order_number, | ||||
|             $model->bill_status_code, | ||||
|             $model->billed_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 [ | ||||
|             'bill_number', | ||||
|             'order_number', | ||||
|             'bill_status_code', | ||||
|             'billed_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 'bills'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										68
									
								
								app/Exports/Purchases/Vendors.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								app/Exports/Purchases/Vendors.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Exports\Purchases; | ||||
|  | ||||
| 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 Vendors implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle | ||||
| { | ||||
|     public $ids; | ||||
|  | ||||
|     public function __construct($ids = null) | ||||
|     { | ||||
|         $this->ids = $ids; | ||||
|     } | ||||
|  | ||||
|     public function collection() | ||||
|     { | ||||
|         $model = Model::type('vendor')->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 'vendors'; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user