Merge branch 'vapor/production' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into vapor/development

# Conflicts:
#	resources/views/pages/pdfs/purchase_order_table.blade.php
#	routes/web.php
This commit is contained in:
edmondlang
2025-02-20 10:32:30 +08:00
8 changed files with 68 additions and 22 deletions
@@ -108,10 +108,12 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
// $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount'));
// $transactionRefundCalculationObject->init();
// full refund
if ((float)$request->input('amount') === (float)$transaction->original_amount) {
$refundAmount = $transaction->original_amount / $transaction->currency_rate;
$service_charges_to_refund = $transaction->service_charge;
} else {
// partial refund
$refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7);
}
@@ -7,6 +7,8 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
use App\Models\Document;
use Illuminate\Support\Facades\Log;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
@@ -42,9 +44,19 @@ class CreateInvoiceDocumentProcessor
*/
public function execute($transaction, $purchaseOrder, $supplier, $document_type, $voucherRedemption = null)
{
// calculate current Paid Amount
$booking = $transaction->owner_type == Booking::class ? $transaction->owner : null;
$currentPaidAmount = null;
if ($booking) {
$payment = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->first();
$refundAmount = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->sum('amount');
$paymentAmount = $payment->amount;
$currentPaidAmount = $paymentAmount - $refundAmount;
}
$lowercaseDocumentType = strtolower($document_type);
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption]);
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption, 'current_paid_amount' => $currentPaidAmount]);
if($purchaseOrder->booking->service_id === 4) {
$purchaseOrderDocuments = $purchaseOrder->booking->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get();
@@ -83,6 +83,12 @@
{{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
</div>
</div>
<div class="col-auto p-l-0" v-if="$store.getters.isSuperAdmin">
<div class="font-heading fs-8 muted all-caps">Service Type</div>
<div class="font-heading fs-10 bold">
{{item.booking.service.name}} ({{item.booking.service.id}})
</div>
</div>
<div class="col-auto" v-if="$store.getters.isAdmin">
<div class="font-heading fs-8 muted all-caps">Supplier</div>
<div class="font-heading fs-10 bold">
+15 -15
View File
@@ -20,22 +20,22 @@ export default {
getCompanyId: (state, getters) => getters.getDecodedAccessToken.user.company_id,
getAccessToken(state, getters, dispatch) {
if(getters.isAuthenticated){
$crisp.push(["set", "user:email", getters.getUserEmail]);
if(getters.isAdmin){
$crisp.push(["set", "user:nickname", getters.getUserName]);
}
// if(getters.isAuthenticated){
// $crisp.push(["set", "user:email", getters.getUserEmail]);
// if(getters.isAdmin){
// $crisp.push(["set", "user:nickname", getters.getUserName]);
// }
if(getters.isCustomer && ('company_marking' in getters.getDecodedAccessToken.user)){
$crisp.push(["set", "user:nickname", getters.getDecodedAccessToken.user.company_marking]);
$crisp.push(["set", "session:data", [
[
["exchange-marking", getters.getDecodedAccessToken.user.company_marking],
["company-name", getters.getDecodedAccessToken.user.company_name]
]
]]);
}
}
// if(getters.isCustomer && ('company_marking' in getters.getDecodedAccessToken.user)){
// $crisp.push(["set", "user:nickname", getters.getDecodedAccessToken.user.company_marking]);
// $crisp.push(["set", "session:data", [
// [
// ["exchange-marking", getters.getDecodedAccessToken.user.company_marking],
// ["company-name", getters.getDecodedAccessToken.user.company_name]
// ]
// ]]);
// }
// }
return state.authentication.access_token
},
@@ -7,5 +7,6 @@
<div style="margin-top: 20px;">
<a href="{{route('booking.details', $booking->marking)}}"><button class="btn all-caps bg-primary no-border text-white pointer" style="font-size: 0.8em" >View</button></a>
</div>
<div class="all-caps hint-text" style="margin-top: 20px;"><small style="font-size: 0.7em">If you have questions, contact us at <a href="https://go.crisp.chat/chat/embed/?website_id=665dcd41-1edf-4451-8cb9-f1cf9ed35e15">here</a>. We truly appreciate your trust in our services and look forward to serving you in the future.</small></div>
<div class="all-caps hint-text" style="margin-top: 20px;"><small style="font-size: 0.7em">If you have questions, contact us at <a href="https://api.whatsapp.com/send?phone=60125639252">here</a>. We truly appreciate your trust in our services and look forward to serving you in the future.</small></div>
<!-- <div class="all-caps hint-text" style="margin-top: 20px;"><small style="font-size: 0.7em">If you have questions, contact us at <a href="https://go.crisp.chat/chat/embed/?website_id=665dcd41-1edf-4451-8cb9-f1cf9ed35e15">here</a>. We truly appreciate your trust in our services and look forward to serving you in the future.</small></div> -->
@endsection
@@ -53,7 +53,14 @@
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Service Charges</td>
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
<?php
$serviceCharge = $transaction->service_charge;
if (isset($current_paid_amount)) {
$refundedServiceCharge = $subtotal + $serviceCharge - $current_paid_amount;
$serviceCharge = $serviceCharge - $refundedServiceCharge + $voucherDiscount;
}
?>
<td class="right">{{ number_format($serviceCharge, 2) }}</td>
</tr>
@if($voucher_redemption)
@@ -72,10 +79,24 @@
</tr>
@endif
@php
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, round($transaction->service_charge, 2), 5), $transaction->tax, 5), $voucherDiscount, 5);
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$displayedSubtotal = is_numeric($displayedSubtotal) ? sprintf('%F', $displayedSubtotal) : '0';
$serviceCharge = is_numeric($serviceCharge) ? sprintf('%F', $serviceCharge) : '0';
$tax = is_numeric($transaction->tax) ? sprintf('%F', $transaction->tax) : '0';
$voucherDiscount = is_numeric($voucherDiscount) ? sprintf('%F', $voucherDiscount) : '0';
$displayedTotal = bcadd(
bcadd(
bcadd($displayedSubtotal, $serviceCharge, 5),
$tax,
5
),
$voucherDiscount,
5
);
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $serviceCharge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$total = bcadd(bcadd(bcadd($subtotal, $serviceCharge, 5), $transaction->tax, 5), $voucherDiscount, 5);
@endphp
<tr>
<td colspan="4"></td>
+1 -1
View File
@@ -6,7 +6,7 @@
'routes' => collect(\Route::getRoutes())->mapWithKeys(function ($route) { return [$route->getName() => $route->uri()]; })
]) !!};
</script>
<script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="665dcd41-1edf-4451-8cb9-f1cf9ed35e15";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
<!-- <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="665dcd41-1edf-4451-8cb9-f1cf9ed35e15";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script> -->
<script src="{{ asset('js/vendor.js') }}" type="text/javascript"></script>
<script src="@if (env('APP_ENV') === 'local') {{asset('vue/app.js')}} @else {{mix('vue/app.js')}} @endif"></script>
<script src="{{ asset('js/site.js') }}" type="text/javascript"></script>
+4
View File
@@ -1355,3 +1355,7 @@ Route::get('/admin-workflow', function () {
Route::get('/admin-workflow/list', function () {
return view('pages.admin-workflow.list-workflow');
})->name('admin-workflow.list');
Route::get('/test-test', function () {
dd('test-test');
});