initial commit

This commit is contained in:
Aqqil Azman
2024-05-13 09:58:28 +08:00
parent 77df383a74
commit 97a8e34f3d
3 changed files with 128 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Group;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromView;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Illuminate\Http\Request;
class ExportCurrencyVendorOrder implements FromView, ShouldAutoSize
{
use Exportable;
private $request;
public function __construct(Request $request)
{
$this->request = $request;
}
public function view(): View
{
$id = $this->request->route('id');
$group = Group::findOrFail($id);
$supplier = $group->issuerCompany;
$transferFeeTransactions = $group->transactions()->with([
'transactions' => function ($transaction) {
return $transaction->where('type', TransactionType::TRANSFER_FEE);
}
])->get()->pluck('transactions')->flatten();
return view('pages.pdfs.currency_vendor_order_inner', [
'transactions' => $group->transactions,
'transferFeeTransactions' => $transferFeeTransactions,
'supplier' => $supplier
]);
}
}
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Exports;
use App\Classes\Modules\Exports\Services\ExportCurrencyVendorOrder;
use App\Classes\Modules\Exports\Services\ExportsCustomers;
use App\Classes\Modules\Exports\Services\ExportsTransactions;
use App\Classes\Modules\Exports\Services\ExportsBookingTransactions;
@@ -36,6 +37,12 @@ class ExportCustomersToExcelController
public function export(ExportsCustomers $exportsCustomers, Request $request){
return $exportsCustomers->download('customers.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
}
public function exportCurrencyVendorOrder(ExportCurrencyVendorOrder $exportCurrencyVendorOrder, Request $request){
$exportCurrencyVendorOrder = new ExportCurrencyVendorOrder($request);
$response = $exportCurrencyVendorOrder->download('CurrencyVendorOrder.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
return $response;
}
public function transactions(ExportsTransactions $exportsTransactions, Request $request){
return $exportsTransactions->download('transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
@@ -0,0 +1,77 @@
<table style="margin-bottom: 25px; border: none;">
<tbody>
<tr>
<td>{{$supplier->name}}</td>
<td>{{\Carbon\Carbon::now('Asia/Singapore')->format('d-m-Y h:s')}}</td>
</tr>
</tbody>
</table>
<br>
<table style="width:100%">
<tbody>
<tr>
<td>Reference</td>
<td>Marking</td>
<td>Rate</td>
<td>Amount</td>
<td>Bank in Details</td>
</tr>
@foreach($transactions as $transaction)
<tr style="margin-bottom: 10px;">
<td>{{$transaction->owner->owner->marking}}</td>
<td>{{$transaction->owner->owner->company->reference}}</td>
<td>{{$transaction->currency_rate}}</td>
<td>{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}</td>
<td>Account Holder Name: {{$transaction->owner->owner->bank->holder_name}}<br>{{$transaction->owner->owner->bank->bank_name}}: {{$transaction->owner->owner->bank->account_no}}
<br>Branch: {{$transaction->owner->owner->bank->bank_branch}}@if($transaction->original_currency->short_code === 'USD')<br>Swift Code: {{$transaction->owner->owner->bank->swift}}@endif<br>Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}}</td>
</tr>
@endforeach
</tbody>
</table>
<table style="margin-bottom: 25px; border: none;">
<tbody>
<tr>
<td width="70%" style="text-align: right;">Sub total booking amount: </td>
@php
$sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', '');
@endphp
<td>{{$transaction->original_currency->short_code}} {{$sub_total_booking_amount}}</td>
</tr>
<tr>
<td width="70%" style="text-align: right;">Transfer fee: </td>
@php
$transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', '');
@endphp
<td>{{$transaction->original_currency->short_code}} {{$transfer_fee}}</td>
</tr>
<tr>
<td width="70%" style="text-align: right;">Total booking amount: </td>
@php
$total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', '');
@endphp
<td>{{$transaction->original_currency->short_code}} {{$total_booking_amount}}</td>
</tr>
<tr>
<td width="70%" style="text-align: right;">Sub total amount: </td>
@php
$sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', '');
@endphp
<td>MYR {{$sub_total_amount}}</td>
</tr>
<tr>
<td width="70%" style="text-align: right;">Service charge: </td>
@php
$service_charge = number_format((float)$transactions->sum('service_charge'), 2, '.', '');
@endphp
<td>MYR {{$service_charge}}</td>
</tr>
<tr>
<td width="70%" style="text-align: right;">Total amount: </td>
@php
$total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', '');
@endphp
<td>MYR {{$total_amount}}</td>
</tr>
</tbody>
</table>