Merge branch 'export-currency-vendor-order-module' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0

This commit is contained in:
edmondlang
2024-05-21 11:16:50 +08:00
8 changed files with 276 additions and 6 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;
@@ -37,6 +38,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']);
+7
View File
@@ -34,6 +34,13 @@ Vue.use(VueTheMask);
Vue.use(filters);
Vue.directive('closable', closable);
Vue.directive('tooltip', function(el, binding){
$(el).tooltip({
title: binding.value,
placement: binding.arg,
trigger: 'hover'
})
})
Vue.mixin({
methods: {
route: route
@@ -13,7 +13,7 @@
<download-supplier-white-form-component section="paymentsReportSection" ></download-supplier-white-form-component>
</div>
</div>
<div class="row">
<div class="row m-b-20">
<div class="col-12 col-md-6">
<div class="row">
<div class="col p-l-0">
@@ -17,6 +17,28 @@
{{item.issuer_name}}
</div>
</div>
<div class="col">
<div class="font-heading fs-10 muted all-caps text-right">Export</div>
<div class="row parentcontainer">
<div class="col d-flex justify-content-end">
<a :href="route('group.text', item.id)" target="_blank" v-tooltip:top="'Export in Text'" class="m-l-5">
<button class="btn btn-xs b-rad-none">
<i class="fa fa-font"></i>
</button>
</a>
<a :href="route('group.excel', item.id)" target="_blank" v-tooltip:top="'Export in Excel'" class="m-l-5">
<button class="btn btn-xs b-rad-none">
<i class="fa fa-file-excel-o"></i>
</button>
</a>
<a :href="route('group.invoice', item.id)" target="_blank" v-tooltip:top="'Export Invoice PDF'" class="m-l-5">
<button class="btn btn-xs b-rad-none">
<i class="fa fa-list-alt"></i>
</button>
</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-auto">
@@ -79,11 +101,6 @@
<div class="col-auto">
<div class="row parentContainer">
<div class="col p-l-0">
<a :href="route('group.text', item.id)" target="_blank">
<button class="btn btn-xs b-rad-none">
<i class="fa fa-align-left"></i>
</button>
</a>
<button class="btn btn-xs btn-complete b-rad-none">
<i class="fa fa-refresh" @click="updateDo()"></i>
</button>
@@ -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;" colspan="4">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;" colspan="4">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;" colspan="4">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;" colspan="4">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;" colspan="4">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;" colspan="4">Total amount: </td>
@php
$total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', '');
@endphp
<td>MYR {{$total_amount}}</td>
</tr>
</tbody>
</table>
@@ -0,0 +1,85 @@
@extends('layouts.base_pdf')
<htmlpageheader name="page-header">
<br>
<table width="100%" style="border-bottom: 1px solid black;">
<tr>
<td style="text-align: center; color: red; text-transform: uppercase; font-weight: bold; font-size: 18px; padding-bottom: 5px;">
{{ $supplier->name }}
</td>
</tr>
</table>
</htmlpageheader>
<table>
<tr>
<td class="title">
<strong>Invoice</strong>
</td>
<td class="document-detail">
PO#: {{$group->reference}} <br>
Ref#: {{$supplier->reference}} <br>
Date: {{$group->created_at}}
</td>
</tr>
</table>
<br>
<table class="buyer-seller">
<tr>
<td width="50%" class="top">
<span class="buyer-seller-title">
Buyer
</span>
<br>
<span class="buyer-company">
CIEF Worldwide Sdn Bhd (1134596-M)
</span>
<div class="address">
No. 72-3, Jalan Jalil 1,<br>
The Earth Bukit Jalil,<br>
57000 Kuala Lumpur
</div>
<div class="contact-no">
Tel: 03-8082 1252
</div>
</td>
</tr>
</table>
<br>
<table class="line-table" style="overflow: wrap" autosize="1">
<thead>
<tr>
<th width="5%">No</th>
<th class="marking" width="10%">Marking</th>
<th class="description">Description</th>
<th width="10%">Currency Rate</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@foreach($transactions as $key => $transaction)
<tr style="margin-bottom: 10px;">
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="marking top" width="10%">{{$transaction->owner->owner->marking}}</td>
<td class="description">Please refer to the appedix reference no: {{$transaction->owner->owner->marking}}</td>
<td width="10%" class="center top">{{$transaction->currency_rate}}</td>
<td>{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}</td>
@php
$sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', '');
$transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', '');
$total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', '');
$sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', '');
$service_charge = number_format((float)$transactions->sum('service_charge'), 2, '.', '');
$total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', '');
@endphp
<td>MYR {{$total_amount}}</td>
</tr>
@endforeach
</tbody>
</table>
+33
View File
@@ -1,7 +1,9 @@
<?php
use App\Classes\Modules\Transactions\ControllersLogic\DownloadMockUpWhiteFormPdfLogic;
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Http\Controllers\Accounting\BankStatementController;
use App\Models\Group;
use App\Models\Remark;
use Carbon\Carbon;
use App\Models\User;
@@ -9,6 +11,7 @@ use App\Models\Wallet;
use App\Models\Booking;
use App\Models\Company;
use App\Models\Transaction;
use Dompdf\Dompdf;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Excel;
@@ -291,6 +294,7 @@ Route::get('/export/imported-receipt-mapped', 'Exports\ExportCustomersToExcelCon
Route::get('/export/analytic/booking', 'Exports\ExportAnalyticToExcelController@bookingData');
Route::get('/export/analytic/bills', 'Exports\ExportAnalyticToExcelController@billingData');
Route::get('/export/customers/leads', 'Exports\ExportCustomersToExcelController@leadsData')->name('leads.export');
route::get('/export/excel/{id}', 'Exports\ExportCustomersToExcelController@exportCurrencyVendorOrder')->name('group.excel');
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
$bookings = Booking::where(function($query){
@@ -537,6 +541,35 @@ Route::get('/group/text/{id}', function($id){
}
})->name('group.text');
Route::get('/group/invoice/{id}', function ($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();
$html = view('pages.pdfs.supplier_deliver_order_group_invoice', [
'group'=> $group,
'transactions' => $group->transactions,
'transferFeeTransactions' => $transferFeeTransactions,
'supplier' => $supplier
])->render();
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
return $dompdf->stream("invoice_pdf_{$supplier->name}.pdf");
})->name('group.invoice');
Route::get('/wallet/audit', function (Request $request) {
$wallets = \App\Models\Wallet::all();