mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-27 16:34:00 +00:00
Merge branch 'dillon/41-voucherify-phase-2a' into development
This commit is contained in:
@@ -93,6 +93,10 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
if (in_array($systemReference, ['exchange', 'izyim'])) {
|
||||
$transaction = $this->checksBillNumber->execute($transactionReference, $systemReference);
|
||||
|
||||
if (is_array($transaction) && empty($transaction)) {
|
||||
throw new MalformedRequestException('Transaction Not Found.');
|
||||
}
|
||||
|
||||
if($systemReference === 'exchange') {
|
||||
$owner_type = Transaction::class;
|
||||
$owner_id = $transaction->id;
|
||||
@@ -112,8 +116,8 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
$transactionType = $transaction['type'];
|
||||
|
||||
if (($payFor === 'sales' && !in_array($transactionType, [ShippingTransactionType::PAYMENT, ShippingTransactionType::GROUP_PAYMENT]))
|
||||
|| ($payFor === 'top_up' && !in_array($transactionType, [ShippingTransactionType::TOP_UP]))) {
|
||||
throw new Exception("Transaction Type does not match");
|
||||
|| ($payFor === 'top_up' && !in_array($transactionType, [ShippingTransactionType::TOP_UP, ShippingTransactionType::GROUP_PAYMENT]))) {
|
||||
throw new MalformedRequestException('Transaction Type does not match.');
|
||||
}
|
||||
|
||||
$owner_type = Transaction::class;
|
||||
|
||||
@@ -20,11 +20,7 @@ class ChecksBillNumber
|
||||
$payload = $data['payload'];
|
||||
return $payload['data'];
|
||||
} catch (\Exception $exception) {
|
||||
dd($exception->getMessage());
|
||||
// preg_match('/\{.*\}/s', $exception->getMessage(), $matches);
|
||||
// $jsonError = json_decode($matches[0]);
|
||||
// Retrieved Transactions failed
|
||||
// throw new MalformedRequestException($jsonError->title);
|
||||
throw new MalformedRequestException($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use Carbon\Carbon;
|
||||
use App\Classes\Modules\Accounting\Processors\ListShippingPortalTransactions;
|
||||
use App\Classes\ValueObjects\Constants\ShippingTransactionType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
@@ -113,12 +114,15 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Fetch Shipping Transaction Fail ' . json_encode([
|
||||
'id' => $transaction->owner_id,
|
||||
'with_company' => true,
|
||||
'StatementTransactionOwner_id' => $transaction->id,
|
||||
]) . PHP_EOL;
|
||||
file_put_contents($errorFilePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Shipping Portal Respnose ' . json_encode($row) . PHP_EOL;
|
||||
file_put_contents($errorFilePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
Log::info('Error in Exports Invoice Transactions ' . $this->counter);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -126,7 +130,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
$row['updated_at'],
|
||||
Carbon::parse($row['updated_at'])->format('m/d/Y H:m'),
|
||||
$row['debtor_code'],
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['marking'],
|
||||
'',
|
||||
|
||||
@@ -14,6 +14,9 @@ class CreateVoucherifyOrderObject implements DataTransferObject
|
||||
/** @var int */
|
||||
private $companyId;
|
||||
|
||||
/** @var int */
|
||||
private $transactionId;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
|
||||
@@ -27,14 +30,16 @@ class CreateVoucherifyOrderObject implements DataTransferObject
|
||||
* CreateVoucherifyOrderObject constructor.
|
||||
* @param User $employee
|
||||
* @param int $companyId
|
||||
* @param int $transactionId
|
||||
* @param float $amount
|
||||
* @param bool $isNoVoucher
|
||||
* @param bool $isTopUpWallet
|
||||
*/
|
||||
public function __construct(User $employee, int $companyId, float $amount, bool $isNoVoucher, bool $isTopUpWallet)
|
||||
public function __construct(User $employee, int $companyId, int $transactionId, float $amount, bool $isNoVoucher, bool $isTopUpWallet)
|
||||
{
|
||||
$this->employee = $employee;
|
||||
$this->companyId = $companyId;
|
||||
$this->transactionId = $transactionId;
|
||||
$this->amount = $amount;
|
||||
$this->isNoVoucher = $isNoVoucher;
|
||||
$this->isTopUpWallet = $isTopUpWallet;
|
||||
@@ -48,6 +53,14 @@ class CreateVoucherifyOrderObject implements DataTransferObject
|
||||
return $this->companyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransactionId(): int
|
||||
{
|
||||
return $this->transactionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
|
||||
@@ -100,7 +100,7 @@ class BookingToVoucherifyProcessor
|
||||
$this->recordVoucherForUserInfo($user, $voucher);
|
||||
}
|
||||
else{
|
||||
$createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $amount, true, $transaction->type == TransactionType::TOP_UP);
|
||||
$createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $transaction->id, $amount, true, $transaction->type == TransactionType::TOP_UP);
|
||||
$createVoucherufyOrderResult = $this->createsVoucherifyOrder->execute($createVoucherifyOrderObject);
|
||||
|
||||
if($createVoucherufyOrderResult && isset($createVoucherufyOrderResult->id)){
|
||||
|
||||
@@ -31,6 +31,7 @@ class CreatesVoucherifyOrder
|
||||
{
|
||||
try {
|
||||
$orderObj = [
|
||||
"source_id" => $obj->getTransactionId(),
|
||||
"customer" => [
|
||||
"source_id" => $obj->getEmployee()->id,
|
||||
"name" => $obj->getEmployee()->name,
|
||||
|
||||
+8
-11
@@ -53,6 +53,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-danger fs-9">{{ error }}</p>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
@@ -60,7 +61,7 @@
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,7 +72,7 @@
|
||||
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
// import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
// import FormHandler from '../../../general/mixins/formHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
@@ -110,20 +111,16 @@
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
this.pay_for_value = this.pay_for_value.replace(/\s/g, "_").toLowerCase();
|
||||
this.system_references = this.system_references ? this.system_references.toLowerCase() : '';
|
||||
|
||||
this.parameters = {
|
||||
pay_for : this.pay_for_value,
|
||||
system_references : this.system_references,
|
||||
pay_for : this.pay_for_value.replace(/\s/g, "_").toLowerCase(),
|
||||
system_references : this.system_references ? this.system_references.toLowerCase() : '',
|
||||
transaction_reference : this.transaction_reference
|
||||
};
|
||||
|
||||
this.submit(this.route('api.accounting.statement.details.update', this.data.id), 'put', this.section, true, true);
|
||||
},
|
||||
successHandler(){
|
||||
// this.closeModal();
|
||||
// this.formHandler('');
|
||||
errorHandler(error){
|
||||
this.error = error.message;
|
||||
},
|
||||
customOptions(){
|
||||
switch (this.pay_for_value) {
|
||||
@@ -136,6 +133,6 @@
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
|
||||
+1
-6
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 100px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
<div class="row text-left no-margin bg-white" 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">
|
||||
@@ -28,11 +27,7 @@
|
||||
props: {
|
||||
section: {
|
||||
type: String,
|
||||
default: 'vouchersDropDownListSection',
|
||||
},
|
||||
isClicked: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: 'availableVouchersSection',
|
||||
},
|
||||
employee: {
|
||||
type: Object,
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 100px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
<div class="row align-items-center justify-content-center bg-white p-t-50 p-b-50" v-show="!isLoading && vouchers.length === 0">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">You have no vouchers</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-left no-margin bg-white" 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>
|
||||
<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">
|
||||
Valid till {{ item.voucher.end_date }}
|
||||
</div>
|
||||
<div class="col" v-else>
|
||||
No expiry date
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
section: {
|
||||
type: String,
|
||||
default: 'vouchersDropDownListSection',
|
||||
},
|
||||
employee: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
vouchers: null,
|
||||
isLoading: true,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pendingQueue () {
|
||||
return this.$store.getters.isInCompleteQueue(this.section);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
pendingQueue(inComplete){
|
||||
if(inComplete){
|
||||
this.fetchVouchers();
|
||||
}
|
||||
},
|
||||
},
|
||||
created(){
|
||||
this.$store.dispatch('updateListQueue', {'name': this.section});
|
||||
},
|
||||
methods: {
|
||||
fetchVouchers(){
|
||||
this.isLoading = true;
|
||||
if(this.employee){
|
||||
this.submit(route('api.voucher.user.list') + '?filters=' + JSON.stringify( { 'has_active_reward': this.employee.id} ), 'get', this.section, false, false);
|
||||
}
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
|
||||
this.vouchers = response.payload.data;
|
||||
},
|
||||
selectVoucher(item){
|
||||
this.$emit('selected-voucher', item.voucher.code);
|
||||
this.closeModal();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -261,7 +261,7 @@
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<!-- <modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
|
||||
<list-vouchers :isClicked="!voucherListDropDownStatus" :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers>
|
||||
<list-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers-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>
|
||||
@@ -270,6 +270,11 @@
|
||||
<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="col">
|
||||
<available-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></available-vouchers-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-5">
|
||||
<div class="col">
|
||||
<div class="row p-l-15 p-r-15">
|
||||
@@ -622,7 +627,6 @@
|
||||
voucherValidated: false,
|
||||
voucherIsChecking: false,
|
||||
showApplyVoucher: false,
|
||||
voucherListDropDownStatus: false,
|
||||
}
|
||||
},
|
||||
validations () {
|
||||
@@ -722,12 +726,8 @@
|
||||
this.voucherValidated = false;
|
||||
this.voucherCode = event.target.value;
|
||||
},
|
||||
toggleDropdown() {
|
||||
this.voucherListDropDownStatus = !this.voucherListDropDownStatus;
|
||||
},
|
||||
handleSelectedVoucher(value){
|
||||
this.voucherCode = value;
|
||||
this.voucherListDropDownStatus = !this.voucherListDropDownStatus;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler],
|
||||
|
||||
Reference in New Issue
Block a user