mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-28 00:43:58 +00:00
107 lines
3.8 KiB
PHP
107 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Exports\Services;
|
|
|
|
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
use App\Models\Company;
|
|
use Maatwebsite\Excel\Concerns\Exportable;
|
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
|
|
class ExportsEInvoiceDebtorSummary implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
{
|
|
|
|
use Exportable;
|
|
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Code',
|
|
'Need Tax INV?',
|
|
'Request Date',
|
|
'TIN NO.',
|
|
'DebtorControlAcc',
|
|
'ControlAccount',
|
|
'CompanyName',
|
|
'Desc2',
|
|
'DebtorType',
|
|
'DisplayTerm',
|
|
'CurrencyCode',
|
|
'RegisterNo',
|
|
'Address1',
|
|
'Address2',
|
|
'Address3',
|
|
'PostCode',
|
|
'DeliverAddr1',
|
|
'DeliverAddr2',
|
|
'DeliverAddr3',
|
|
'DeliverPostCode',
|
|
'EmailAddress',
|
|
'Attention',
|
|
'Phone1',
|
|
'Phone2',
|
|
'Fax1'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Support\Collection|mixed
|
|
*/
|
|
public function query()
|
|
{
|
|
return Company::where(function($query){
|
|
// $query->whereNull('debtor')->orWhere('debtor', '');
|
|
$query->whereNotNull('e_invoice');
|
|
})->whereNotIn('id', [2207, 2248, 2029])->where('business_type', BusinessType::IMPORTER)->where('status', ApprovalStatus::APPROVED)->where(function($query){
|
|
$query->whereHas('transactions', function($query){
|
|
return $query->whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP])->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::PENDING_VERIFICATION]);
|
|
})->orWhereHas('wallets', function($query){
|
|
return $query->whereHas('transactions');
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param Company $company
|
|
*
|
|
* @return array
|
|
*/
|
|
public function map($company): array
|
|
{
|
|
return [
|
|
'<<New>>', // Code
|
|
$company->e_invoice, // Need Tax INV?
|
|
$company->e_invoice_requested_at, // Request Date
|
|
$company->tin, // TIN NO.
|
|
'300-0000', // DebtorControlAcc
|
|
'300-0000', // ControlAccount
|
|
$company->name.' (PURCHASE)', // CompanyName
|
|
$company->reference, // Desc2
|
|
'', // DebtorType
|
|
'PIA', // DisplayTerm
|
|
'MYR', // CurrencyCode
|
|
'', // RegisterNo
|
|
'', // Address1
|
|
'', // Address2
|
|
'', // Address3
|
|
'', // PostCode
|
|
'', // DeliverAddr1
|
|
'', // DeliverAddr2
|
|
'', // DeliverAddr3
|
|
'', // DeliverPostCode
|
|
'', // EmailAddress
|
|
'', // Attention
|
|
'', // Phone1
|
|
'', // Phone2
|
|
'', // Fax1
|
|
];
|
|
}
|
|
}
|