Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0 into front-end-bootstrap

This commit is contained in:
Aqqil Azman
2024-05-24 10:04:45 +08:00
6 changed files with 127 additions and 6 deletions
@@ -38,4 +38,23 @@ final class TransactionType {
public const BILL_REFUND = 16;
}
public const ID_TO_NAME = [
self::PAYMENT_ATTEMPT => "PAYMENT_ATTEMPT",
self::PAYMENT => "PAYMENT",
self::INVOICE => "INVOICE",
self::BILL => "BILL",
self::PROFORMA => "PROFORMA",
self::TOP_UP => "TOP_UP",
self::REFUND => "REFUND",
self::PURCHASE_ORDER => "PURCHASE_ORDER",
self::SUPPLIER_DELIVER => "SUPPLIER_DELIVER",
self::CREDIT_NOTE => "CREDIT_NOTE",
self::DEBIT_NOTE => "DEBIT_NOTE",
self::WITHDRAW => "WITHDRAW",
self::TRANSFER_FEE => "TRANSFER_FEE",
self::CASH_BACK => "CASH_BACK",
self::SUPPLIER_PAYMENT => "SUPPLIER_PAYMENT",
self::SUPPLIER_REFUND => "SUPPLIER_REFUND",
];
}
+2 -1
View File
@@ -56,7 +56,8 @@ class BookingResource extends JsonResource
->whereDate('expires_on', '>=', Carbon::now())
->get()
),
'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()),
// 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()),
'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::EXPIRED)->get()),
'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){
$query->where(function($query){
$query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED, ApprovalStatus::REFUNDED]);
@@ -289,7 +289,7 @@
</div>
</div>
</div>
<div class="row m-t-10" v-show="!hasRefundInProgress && [2, 3].includes(item.status) && (totalRequestedRefund + totalRefunds) < data.original_amount">
<div class="row m-t-10" v-show="[2, 3].includes(item.status) && (totalRequestedRefund + totalRefunds) < data.original_amount">
<div class="col" v-if="$store.getters.isAdmin">
<button class="btn btn-xs all-caps b-rad-none bg-master-lighter btn-block no-border requestModal" data-type="transferSummary">Request Refund</button>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="transferSummary" size="large">
@@ -319,7 +319,7 @@
<div class="row" v-if="data.transaction_refunds.length > 0 && expandRefundTransactions">
<div class="col bg-white padding-15">
<div class="b-b b-grey m-b-5" v-for="(refund, index) in data.transaction_refunds">
<div class="row m-b-10">
<div class="row m-b-10 parentContainer">
<div class="col-auto">
<div class="font-heading fs-10 muted all-caps">Created At</div>
<div class="font-heading fs-10">
@@ -67,7 +67,7 @@
<script>
import FormHandler from '../../../general/mixins/formHandler';
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
import { maxValue } from "vuelidate/lib/validators";
import { maxValue, required } from "vuelidate/lib/validators";
export default {
props: {
@@ -92,7 +92,9 @@ export default {
refundAmount: {
maxValue: maxValue(this.refundMaxValue)
},
refundRemark: {}
refundRemark: {
required
}
}
},
computed: {
@@ -25,6 +25,14 @@
<a :href="route('customer.profile', data.booking.company.reference)">{{data.booking.company.reference}}</a>
</div>
</div>
<div class="col-auto" v-if="$store.getters.isAdmin">
<span class="btn requestModal no-border" size="large" data-type="chatmodal">
<i class="fa fa-comment-o"></i>
</span>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="chatmodal">
<remark-component :section="section" :data="data" module_type="Transaction"></remark-component>
</modal-component>
</div>
<div class="col text-right">
<div class="font-heading fs-10 muted all-caps">Amount</div>
<div class="font-heading fs-14 text-success bold">
+91
View File
@@ -33,6 +33,7 @@ use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
use App\Classes\Modules\Documents\Services\DeletesDocument;
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionWithInvoiceNoProcessor;
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -475,6 +476,7 @@ Route::get('/approve_refunds', function(Request $request){
echo '<td>Last Updated At</td>';
echo '<td>Bank Type</td>';
echo '<td>Bank Holder Name</td>';
echo '<td>Note Remark</td>';
echo '</tr>';
foreach ($payments->orderBy('updated_at', 'DESC')->get() as $index => $payment){
$booking = $payment->owner;
@@ -499,6 +501,14 @@ Route::get('/approve_refunds', function(Request $request){
$remark = 'Pre ' . $remark;
}
$refundTransactions = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$noteRemark = '';
foreach ($refundTransactions as $refund) {
$noteRemark .= implode(', ', $refund->remarks->pluck('content')->toArray()) . ' ';
}
echo '<tr>';
echo '<td>'.($index + 1).'.</td>';
echo '<td>'.$payment->updated_at->format('d-M-y').'</td>';
@@ -516,6 +526,7 @@ Route::get('/approve_refunds', function(Request $request){
echo '<td>'.$payment->updated_at->diffForHumans().'</td>';
echo '<td>'.$bankType.'</td>';
echo '<td>'.$booking->bank->holder_name.'</td>';
echo '<td>'.$noteRemark.'</td>';
echo '</tr>';
}
echo '</table>';
@@ -1105,3 +1116,83 @@ Route::get('/show-white-form-transactions-in-date-range/{from_date}/{to_date}',
echo '</tbody>';
echo '</table>';
});
Route::get('check-duplicate-refunds', function () {
$results = Transaction::select('payment_reference', 'owner_id', 'owner_type', 'type', 'status', 'amount', DB::raw('COUNT(*) as count'))
->whereNotNull('payment_reference')
->where('payment_reference', '<>', '')
->where('payment_reference', '<>', 'Withdraw')
->where('payment_reference', '<>', 'Refund for Ref. 77315')
->whereNull('deleted_at')
->groupBy('payment_reference', 'owner_id', 'owner_type', 'type', 'status', 'amount')
->having(DB::raw('COUNT(*)'), '>', 1)
->get();
$transactionType = TransactionType::ID_TO_NAME;
$approvalStatus = ApprovalStatus::APPROVAL_STATUS_ID;
echo '<table style="border-collapse: collapse; width: 100%;">';
echo '<thead>';
echo '<tr>';
echo '<th style="border: 1px solid black;">Owner Type</th>';
echo '<th style="border: 1px solid black;">Owner ID</th>';
echo '<th style="border: 1px solid black;">Payment Reference</th>';
echo '<th style="border: 1px solid black;">Type</th>';
echo '<th style="border: 1px solid black;">Status</th>';
echo '<th style="border: 1px solid black;">Count</th>';
echo '<th style="border: 1px solid black;">Amount</th>';
echo '<th style="border: 1px solid black;">Wallet Details</th>';
echo '<th style="border: 1px solid black;">Booking Ref</th>';
echo '<th style="border: 1px solid black;">Payment ID</th>';
echo '<th style="border: 1px solid black;">Payment Status</th>';
echo '<th style="border: 1px solid black;">Refund ID</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ($results as $result) {
$booking_ref_arr = explode(' ', $result->payment_reference);
$booking_ref = end($booking_ref_arr);
echo '<tr>';
echo "<td style='border: 1px solid black;'>$result->owner_type</td>";
echo "<td style='border: 1px solid black;'>$result->owner_id</td>";
echo "<td style='border: 1px solid black;'>$result->payment_reference</td>";
$status = $transactionType[$result->type];
echo "<td style='border: 1px solid black;'>$status</td>";
$approvalsName = $approvalStatus[$result->status];
echo "<td style='border: 1px solid black;'>$approvalsName</td>";
echo "<td style='border: 1px solid black;'>$result->count</td>";
echo "<td style='border: 1px solid black;'>$result->amount</td>";
$click = null;
if ($result->owner_type == 'App\Models\Wallet') {
$click = '<a href="'.route('wallet.details', $result->owner->owner->reference).'" target="_blank">'.$result->owner->owner->reference.'</a>';
}
echo "<td style='border: 1px solid black;'>". $click ."</td>";
$booking_ref_click = null;
$payment = null;
$refund = null;
if ($booking_ref) {
$booking_ref_click = '<a href="'.route('booking.details', $booking_ref).'" target="_blank">'.$booking_ref.'</a>';
$booking = Booking::where('marking', $booking_ref)->first();
if ($booking) {
$payment = $booking->transactions()->where('type', TransactionType::PAYMENT)->first();
$refund = $payment->transactions()->where('type', TransactionType::REFUND)->get()->pluck('id')->toArray();
$refund = implode(',', $refund);
}
}
echo "<td style='border: 1px solid black;'>$booking_ref_click</td>";
echo "<td style='border: 1px solid black;'>" . ($payment ? $payment->id : '') . "</td>";
echo "<td style='border: 1px solid black;'>" . ($payment ? $approvalStatus[$payment->status] : '') . "</td>";
echo "<td style='border: 1px solid black;'>" . ($refund ? $refund : '') . "</td>";
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
});