mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - e-Invoice debtor report
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?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', '');
|
||||
})->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
|
||||
'TODO', // Need Tax INV?
|
||||
'TODO', // Request Date
|
||||
'TODO', // 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
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -72,28 +72,28 @@ class ExportsNullDebtors implements FromQuery, WithHeadings, WithHeadingRow, Wit
|
||||
public function map($company): array
|
||||
{
|
||||
return [
|
||||
'<<New>>',
|
||||
'300-0000',
|
||||
'300-0000',
|
||||
$company->name.' (PURCHASE)',
|
||||
$company->reference,
|
||||
'',
|
||||
'PIA',
|
||||
'MYR',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',//EmailAddress
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
'<<New>>', // Code
|
||||
'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
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,16 @@ use App\Classes\Modules\Exports\Services\ExportsNullDebtors;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWalletTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsInvoiceTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsReceiptTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedReceiptMappeds;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWhiteFormTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedInvoiceMappeds;
|
||||
use App\Classes\Modules\Exports\Services\ExportsEInvoiceDebtorSummary;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedInvoiceMappeds;
|
||||
use App\Models\TransactionMappingLog;
|
||||
use App\Classes\Modules\Exports\Services\ExportsReceiptTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedReceiptMappeds;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWhiteFormTransactions;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -241,5 +242,17 @@ class ExportCustomersToExcelController
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function eInvoiceDebtorSummary(ExportsEInvoiceDebtorSummary $exportsEInvoiceDebtorSummary, Request $request){
|
||||
$exportFileName = 'EINV_DEBTOR_SUMMARY.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsEInvoiceDebtorSummary) ]);
|
||||
}
|
||||
else{
|
||||
$response = $exportsEInvoiceDebtorSummary->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,34 @@
|
||||
<show-white-form-transactions-component></show-white-form-transactions-component>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-3">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span>nullDebtor.xls</span>
|
||||
<p class="text-muted mb-0">New Debtors Report from <a href="{{route('settings')}}" target="_blank">settings page</a></p>
|
||||
</div>
|
||||
<open-link-in-new-tab-component custom-class="btn btn-primary" :url="route('newDebtor.export')">
|
||||
<i class="fa fa-download"></i> Download
|
||||
</open-link-in-new-tab-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-3">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span>EINV_DEBTOR_SUMMARY.xls</span>
|
||||
<p class="text-muted mb-0">e-Invoice Debtor Summary Report</p>
|
||||
</div>
|
||||
<open-link-in-new-tab-component custom-class="btn btn-primary" :url="route('eInvoiceDebtorSummary.export')">
|
||||
<i class="fa fa-download"></i> Download
|
||||
</open-link-in-new-tab-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Group 2: XXX Downloads -->
|
||||
|
||||
+10
-9
@@ -326,6 +326,7 @@ Route::get('/export/analytic/booking', 'Exports\ExportAnalyticToExcelController@
|
||||
Route::get('/export/analytic/bills', 'Exports\ExportAnalyticToExcelController@billingData')->name('billingData.export');;
|
||||
Route::get('/export/customers/leads', 'Exports\ExportCustomersToExcelController@leadsData')->name('leads.export');
|
||||
route::get('/export/excel/{id}', 'Exports\ExportCustomersToExcelController@exportCurrencyVendorOrder')->name('group.excel');
|
||||
Route::get('/export/einv-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@eInvoiceDebtorSummary')->name('eInvoiceDebtorSummary.export');
|
||||
|
||||
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
|
||||
$bookings = Booking::where(function($query){
|
||||
@@ -1202,42 +1203,42 @@ Route::get('/show-white-form-transactions-in-date-range/{from_date}/{to_date}',
|
||||
const fileInput = form.querySelector("input[type=\'file\']");
|
||||
const files = fileInput.files;
|
||||
const userToken = localStorage.getItem("user-token");
|
||||
|
||||
|
||||
if (files.length === 0) {
|
||||
alert("Please select at least one file to upload.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const fileReaders = [];
|
||||
let totalFiles = files.length;
|
||||
|
||||
|
||||
// Create a promise for each file to read it as Base64
|
||||
Array.from(files).forEach((file) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
|
||||
// Create a promise that resolves when the file is read
|
||||
const fileReadPromise = new Promise((resolve, reject) => {
|
||||
reader.onload = (event) => {
|
||||
resolve(event.target.result);
|
||||
};
|
||||
|
||||
|
||||
reader.onerror = (error) => {
|
||||
reject(error);
|
||||
};
|
||||
|
||||
|
||||
reader.readAsDataURL(file); // Read the file as Data URL (Base64)
|
||||
});
|
||||
|
||||
|
||||
fileReaders.push(fileReadPromise);
|
||||
});
|
||||
|
||||
|
||||
// Wait for all files to be read
|
||||
Promise.all(fileReaders)
|
||||
.then((fileData) => {
|
||||
const payload = {
|
||||
files: fileData, // Array of objects with name, type, and Base64 content
|
||||
};
|
||||
|
||||
|
||||
// Send the payload as JSON
|
||||
return fetch(`/api/v1/transactions/${billId}/bill/verification`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user