open partial refund, categorize refunds section in dashboard

This commit is contained in:
JiaSheng
2024-03-06 20:56:24 +08:00
parent e7ef63c511
commit 73819e967e
5 changed files with 137 additions and 8 deletions
@@ -0,0 +1,26 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
class IsPartialRefund implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('owner', function ($q) use ($value) {
if ($value) {
$q->where('original_amount', '!=', DB::raw('transactions.original_amount'));
} else {
$q->where('original_amount', DB::raw('transactions.original_amount'));
}
});
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class OwnerDoesNotHaveTransactionType implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereDoesntHave('owner', function($query) use($value) {
return $query->whereHas('transactions', function($query) use($value) {
return $query->where('transactions.type', $value);
});
});
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class OwnerHasTransactionType implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('owner', function($query) use($value) {
return $query->whereHas('transactions', function($query) use($value) {
return $query->where('transactions.type', $value);
});
});
}
}
@@ -38,6 +38,7 @@
<div class="row m-t-10 m-b-10">
<div class="col">
<div class="font-heading all-caps fs-10 m-b-5">Paid Amount: {{ paidAmount }}</div>
<div class="font-heading all-caps fs-10 m-b-5" v-if="this.data.refunded_amount > 0">Paid Amount: {{ (Math.round((this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2) }}</div>
<div class="font-heading all-caps fs-10 m-b-5">Refund Amount: {{ refundAmount }}</div>
</div>
</div>
@@ -69,10 +70,11 @@ export default {
},
data() {
return {
refundAmount: (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2),
refundMethod: { name: 'Fully Refund', status: false },
refundMethods: [
{ name: 'Fully Refund', label: 'Full Refund' },
// { name: 'Partially Refund', label: 'Partial Refund' }
{ name: 'Partially Refund', label: 'Partial Refund' }
]
}
},
@@ -84,12 +86,8 @@ export default {
}
},
computed: {
refundAmount() {
// return (Math.round((this.data.booking.amount - this.totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2);
return (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2);
},
refundMaxValue() {
return this.refundAmount;
return (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2);
},
paidAmount() {
return this.data.original_amount;
@@ -81,11 +81,68 @@
</div>
<div class="row tabsContainer hide tabContent" tab-name="refunds">
<div class="col">
<div class="row m-b-15 p-b-10 b-b b-grey">
<div class="col">
<small class="all-caps muted fs-14 bold">Pre-Refund</small>
</div>
</div>
<div class="row m-b-15 p-b-10 b-grey">
<div class="col text-center">
<small class="all-caps muted fs-10">Fully Refund</small>
</div>
</div>
<div class="row">
<div class="col">
<list-component key="2" section="listRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1}">
<list-component key="2" section="listPreFullRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_does_not_have_transaction_type: 3, is_partial_refund: false}">
<template slot="list" slot-scope="{data}">
<refund-verification-component section="listRefundTransactionSection" :data="data"></refund-verification-component>
<refund-verification-component section="listPreFullRefundTransactionSection" :data="data"></refund-verification-component>
</template>
</list-component>
</div>
</div>
<div class="row m-b-15 p-b-10 b-grey">
<div class="col text-center">
<small class="all-caps muted fs-10">Partial Refund</small>
</div>
</div>
<div class="row">
<div class="col">
<list-component key="3" section="listPrePartialRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_does_not_have_transaction_type: 3, is_partial_refund: true}">
<template slot="list" slot-scope="{data}">
<refund-verification-component section="listPrePartialRefundTransactionSection" :data="data"></refund-verification-component>
</template>
</list-component>
</div>
</div>
<div class="row m-b-15 p-b-10 p-t-10 b-t b-b b-grey">
<div class="col">
<small class="all-caps muted fs-14 bold">Post-Refund</small>
</div>
</div>
<div class="row m-b-15 p-b-10 b-grey">
<div class="col text-center">
<small class="all-caps muted fs-10">Fully Refund</small>
</div>
</div>
<div class="row">
<div class="col">
<list-component key="4" section="listPostFullRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_has_transaction_type: 3, is_partial_refund: false}">
<template slot="list" slot-scope="{data}">
<refund-verification-component section="listPostFullRefundTransactionSection" :data="data"></refund-verification-component>
</template>
</list-component>
</div>
</div>
<div class="row m-b-15 p-b-10 b-grey">
<div class="col text-center">
<small class="all-caps muted fs-10">Partial Refund</small>
</div>
</div>
<div class="row">
<div class="col">
<list-component key="5" section="listPostPartialRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_has_transaction_type: 3, is_partial_refund: true}">
<template slot="list" slot-scope="{data}">
<refund-verification-component section="listPostPartialRefundTransactionSection" :data="data"></refund-verification-component>
</template>
</list-component>
</div>