Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into refund-booking

This commit is contained in:
edmondlang
2024-02-06 12:02:06 +08:00
4 changed files with 28 additions and 17 deletions
@@ -44,10 +44,16 @@ class ValidateVoucherLogic extends AbstractControllerLogic
{
$booking = Booking::find($request->input('itemId'));
$employee = $booking->company->employees()->first();
$amount = $this->floatvalue($request->input('amount'));
$validateVoucherifyVoucherObject = new ValidateVoucherifyVoucherObject($booking->company_id, $request->input('voucherCode'), $request->input('amount'), $employee);
$validateVoucherifyVoucherObject = new ValidateVoucherifyVoucherObject($booking->company_id, $request->input('voucherCode'), $amount, $employee);
$result = $this->validatesVoucherifyVoucher->execute($validateVoucherifyVoucherObject);
return $this->response(['data' => $result]);
}
private function floatvalue($val){
$val = str_replace(",",".",$val);
$val = preg_replace('/\.(?=.*\.)/', '', $val);
return floatval($val);
}
}
@@ -3,6 +3,7 @@
namespace App\Classes\Modules\Vouchers\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
use Carbon\Carbon;
use DateTime;
use Illuminate\Support\Facades\Log;
@@ -86,7 +87,8 @@ class VoucherObject implements DataTransferObject
{
try {
if(!$this->startDate) return null;
$dateTime = new DateTime($this->startDate);
// $dateTime = new DateTime($this->startDate);
$dateTime = Carbon::parse($this->startDate)->tz('Asia/Kuala_Lumpur');
return $dateTime;
} catch (\Exception $e) {
Log::error($e);
@@ -101,7 +103,7 @@ class VoucherObject implements DataTransferObject
{
try {
if(!$this->endDate) return null;
$dateTime = new DateTime($this->endDate);
$dateTime = Carbon::parse($this->endDate)->tz('Asia/Kuala_Lumpur');
return $dateTime;
} catch (\Exception $e) {
Log::error($e);
@@ -1,20 +1,23 @@
<template>
<div class="row">
<div class="col">
<div class="row text-left no-margin bg-white" v-if="!isLoading" v-for="item in vouchers" v-bind:key="item.id" >
<div v-if="vouchers && vouchers.length > 0" class="row fs-10 p-b-5">List of Vouchers, click to select</div>
<div class="row text-left no-margin bg-white p-b-10" v-if="!isLoading" v-for="item in vouchers" v-bind:key="item.id" >
<div id="select-option" name="select-option" class="col b-b b-grey p-t-10 p-b-10 pointer p-t-10 p-b-10" @click="selectVoucher(item)">
<div class="row parentContainer">
<div class="col">
<p>{{ item.voucher.code }}</p>
<div class="row">
<!-- <div class="col">
<p v-if="item.voucher.type == 'AMOUNT'">RM{{ item.voucher.value/100 }} Discount</p>
<p v-if="item.voucher.type == 'PERCENT'">{{ item.voucher.value }}% Discount</p>
</div>
<div class="col" v-if="item.voucher.end_date">
</div> -->
<span>{{ item.voucher.code }}</span>
</div>
<div class="row">
<span v-if="item.voucher.end_date">
Valid till {{ item.voucher.end_date }}
</div>
<div class="col" v-else>
</span>
<span v-else>
No expiry date
</div>
</span>
</div>
</div>
</div>
@@ -252,21 +252,21 @@
</div>
</validation-wrapper-component>
</div>
<!-- <modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
<modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
<list-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers-component>
</modal-component> -->
</modal-component>
</div>
<span class="text-primary bold text-underline m-l-5 cursor text-small fs-12" style="margin-bottom: -10px; margin-top: -5px;" @click="showApplyVoucher=!showApplyVoucher" v-show="!showApplyVoucher">Apply a voucher</span>
<div class="row m-l-0 m-r-0" style="height: 20px">
<div class="row m-l-0 m-r-0" v-show="showApplyVoucher" style="height: 20px">
<i class="fa fa-spinner fa-spin m-b-5" v-if="voucherIsChecking"></i>
<span class="text-danger" v-if="voucherCodeFailedReason">{{ voucherCodeFailedReason }}</span>
<span class="text-success" v-if="voucherCodeFailedReason === '' && voucherValidated">Voucher applied</span>
</div>
<!-- <div class="row m-l-0 m-r-0">
<div class="row m-l-0 m-r-0" v-show="showApplyVoucher">
<div class="col">
<available-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></available-vouchers-component>
</div>
</div> -->
</div>
<div class="row m-t-5">
<div class="col">
<div class="row p-l-15 p-r-15">