diff --git a/app/Classes/Modules/Exports/Services/ExportCurrencyVendorOrder.php b/app/Classes/Modules/Exports/Services/ExportCurrencyVendorOrder.php new file mode 100644 index 00000000..2d3a79f9 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportCurrencyVendorOrder.php @@ -0,0 +1,44 @@ +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 + ]); + } +} diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 0f351c7d..c7354a0d 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -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']); diff --git a/resources/views/pages/pdfs/currency_vendor_order_inner.blade.php b/resources/views/pages/pdfs/currency_vendor_order_inner.blade.php new file mode 100644 index 00000000..bd289a94 --- /dev/null +++ b/resources/views/pages/pdfs/currency_vendor_order_inner.blade.php @@ -0,0 +1,77 @@ + +
| {{$supplier->name}} | +{{\Carbon\Carbon::now('Asia/Singapore')->format('d-m-Y h:s')}} | +
| Reference | +Marking | +Rate | +Amount | +Bank in Details | +
| {{$transaction->owner->owner->marking}} | +{{$transaction->owner->owner->company->reference}} | +{{$transaction->currency_rate}} | +{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}} | +Account Holder Name: {{$transaction->owner->owner->bank->holder_name}} {{$transaction->owner->owner->bank->bank_name}}: {{$transaction->owner->owner->bank->account_no}} + Branch: {{$transaction->owner->owner->bank->bank_branch}}@if($transaction->original_currency->short_code === 'USD') Swift Code: {{$transaction->owner->owner->bank->swift}}@endif Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} |
+
| Sub total booking amount: | + @php + $sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', ''); + @endphp +{{$transaction->original_currency->short_code}} {{$sub_total_booking_amount}} | +
| Transfer fee: | + @php + $transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', ''); + @endphp +{{$transaction->original_currency->short_code}} {{$transfer_fee}} | +
| Total booking amount: | + @php + $total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', ''); + @endphp +{{$transaction->original_currency->short_code}} {{$total_booking_amount}} | +
| Sub total amount: | + @php + $sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', ''); + @endphp +MYR {{$sub_total_amount}} | +
| Service charge: | + @php + $service_charge = number_format((float)$transactions->sum('service_charge'), 2, '.', ''); + @endphp +MYR {{$service_charge}} | +
| Total amount: | + @php + $total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', ''); + @endphp +MYR {{$total_amount}} | +