mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Exports\Services;
|
|
|
|
use App\Classes\General\Eloquent\Filters\ServiceType;
|
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
use App\Models\Booking;
|
|
use App\Models\Company;
|
|
use App\Models\Transaction;
|
|
use Maatwebsite\Excel\Concerns\Exportable;
|
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Carbon\Carbon;
|
|
|
|
class ExportsAnalyticBillingTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
{
|
|
use Exportable;
|
|
|
|
private $request;
|
|
|
|
public function __construct(Request $request)
|
|
{
|
|
$this->request = $request;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Booking Id',
|
|
'Service Type',
|
|
'Payment Method',
|
|
'Company Id',
|
|
'Customer Segment',
|
|
'Company Create Date',
|
|
'Company Type',
|
|
'Supplier Id',
|
|
'Customer Payment',
|
|
'Customer Rate',
|
|
'Customer Service Charge',
|
|
'Customer Payment Date',
|
|
'Original Amount',
|
|
'Supplier Payment',
|
|
'Supplier Rate',
|
|
'Supplier Sevice Charge',
|
|
'Supplier Payment Date'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Support\Collection|mixed
|
|
*/
|
|
public function query()
|
|
{
|
|
return Transaction::where('type', 3);
|
|
}
|
|
|
|
/**
|
|
* @param $transaction
|
|
* @return array
|
|
*/
|
|
public function map($transaction): array
|
|
{
|
|
dd($transaction->owner->owner->company);
|
|
|
|
$paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID;
|
|
$paymentMethod = $paymentmethondArray[$transaction->payment_method];
|
|
|
|
$companyTypeArray = CompanyType::COMPANY_TYPE_ID;
|
|
$companyType = $companyTypeArray[$transaction->owner->owner->company->business_type];
|
|
|
|
return [
|
|
$transaction->id,
|
|
$transaction->booking->service->name,
|
|
$paymentMethod,
|
|
$transaction->owner->owner->company->id,
|
|
$transaction->owner->owner->company->segments->first()->name,
|
|
$transaction->owner->owner->company->created_at,
|
|
|
|
];
|
|
}
|
|
} |