mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Edit book recipient bank details
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\BookingResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\UpdatesBooking;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateBookingRecipientLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Booking',
|
||||
'message' => 'You have successfully updated the Booking'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateBooking */
|
||||
private $canUpdateBooking;
|
||||
|
||||
/** @var UpdatesBooking */
|
||||
private $updatesBooking;
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateBookingRecipientLogic constructor.
|
||||
* @param CanUpdateBooking $canUpdateBooking
|
||||
* @param UpdatesBooking $updatesBooking
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBooking $canUpdateBooking,
|
||||
UpdatesBooking $updatesBooking,
|
||||
FetchesBooking $fetchesBooking
|
||||
)
|
||||
{
|
||||
$this->canUpdateBooking = $canUpdateBooking;
|
||||
$this->updatesBooking = $updatesBooking;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
$booking_object = new BookingObject(
|
||||
$booking->service_id,
|
||||
$request->input('transferable_bank_id', $booking->transferable_bank_id),
|
||||
$booking->marking,
|
||||
$booking->fix_amount,
|
||||
$booking->fix_currency_id,
|
||||
$booking->convertible_currency_id,
|
||||
$booking->conversion_currency_id
|
||||
);
|
||||
$this->canUpdateBooking->passes($booking_object);
|
||||
$booking = $this->updatesBooking->execute($booking, $booking_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new BookingResource($booking));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\UpdateBookingRecipientLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateBookingRecipientController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateBookingRecipientLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateBookingRecipientLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,9 +136,12 @@
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :data-dismiss="closable ? 'modal' : ''" @click="$emit('close')">{{disabled ? 'Change Recipient Account' : 'Cancel'}}</div>
|
||||
</div>
|
||||
<div class="col p-l-5" v-if="!disabled">
|
||||
<div class="col p-l-5" v-if="!disabled && !isEditing">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Add Account</div>
|
||||
</div>
|
||||
<div class="col p-l-5" v-if="isEditing">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update Details</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,6 +182,10 @@
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'RMB'
|
||||
},
|
||||
isEditing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
@@ -224,10 +231,22 @@
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
this.submit(route('api.bank.create'), 'post', this.section, true, false);
|
||||
if(this.isEditing){
|
||||
this.parameters.company_id = this.company_id;
|
||||
this.parameters.account_type = this.type;
|
||||
this.submit(route('api.bank.update', this.parameters.id), 'put', this.section, true, false);
|
||||
}
|
||||
else{
|
||||
this.submit(route('api.bank.create'), 'post', this.section, true, false);
|
||||
}
|
||||
},
|
||||
successHandler(response){
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('createdBank', response.payload.data);
|
||||
if(this.isEditing){
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('updatedBankDetails', response.payload.data);
|
||||
}
|
||||
else{
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('createdBank', response.payload.data);
|
||||
}
|
||||
this.formHandler();
|
||||
this.resetForm();
|
||||
},
|
||||
|
||||
@@ -42,9 +42,12 @@
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :data-dismiss="closable ? 'modal' : ''" @click="$emit('close')">{{disabled ? 'Change Recipient Account' : 'Cancel'}}</div>
|
||||
</div>
|
||||
<div class="col p-l-5" v-if="!disabled">
|
||||
<div class="col p-l-5" v-if="!disabled && !isEditing">
|
||||
<button class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Add Account</button>
|
||||
</div>
|
||||
<div class="col p-l-5" v-if="isEditing">
|
||||
<button class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update Details</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,6 +83,10 @@
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null
|
||||
},
|
||||
isEditing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
@@ -115,10 +122,22 @@
|
||||
submitForm(){
|
||||
this.parameters.account_type = 3;
|
||||
this.parameters.bank_name = '-';
|
||||
this.submit(route('api.bank.create'), 'post', this.section, true, false);
|
||||
if(this.isEditing){
|
||||
this.parameters.company_id = this.company_id;
|
||||
this.parameters.account_type = this.type;
|
||||
this.submit(route('api.bank.update', this.parameters.id), 'put', this.section, true, false);
|
||||
}
|
||||
else{
|
||||
this.submit(route('api.bank.create'), 'post', this.section, true, false);
|
||||
}
|
||||
},
|
||||
successHandler(response){
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('createdBank', response.payload.data);
|
||||
if(this.isEditing){
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('updatedBankDetails', response.payload.data);
|
||||
}
|
||||
else{
|
||||
this.type !== 2 ? this.closeModal() : this.$emit('createdBank', response.payload.data);
|
||||
}
|
||||
this.formHandler();
|
||||
this.resetForm();
|
||||
},
|
||||
@@ -140,4 +159,4 @@
|
||||
mixins: [FormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div class="row zig-zag-top">
|
||||
<div class="col bg-white padding-25">
|
||||
<div class="row p-b-20 b-b b-dashed b-grey m-b-20">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps bold fs-10">Recipient Details</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="row parentContainer">
|
||||
<div class="col">
|
||||
<div class="row" v-show="!createBank && !isEditing">
|
||||
<div class="col-7 p-r-0">
|
||||
<div class="row" id="select-list" name="select-list">
|
||||
<div class="col">
|
||||
<div class="form-group no-margin form-group-default">
|
||||
<label>{{ data.serviceType.id === 4 ? '1688 Login Id/Email/Phone' : 'Account No.' }}</label>
|
||||
<input type="text" class="form-control" v-model="account_no" @keyup="parameters.bankAccount = {}" @focus="dropdownStatus = true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="relative w-100">
|
||||
<div class="absolute w-100 b-l b-b b-r b-grey" :class="[{'hide': !dropdownStatus}]" style="top: 100%; right: 0; z-index: 1;">
|
||||
<div class="row text-left no-margin bg-white">
|
||||
<div class="col no-padding">
|
||||
<div class="row no-margin" v-for="bank in data.recipientBanks.filter(AccountNumber)" v-bind:key="bank.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" :class="['bg-master-lightest','text-master', 'hover-primary', 'pointer']" @click="selectBank(bank)">
|
||||
<div class="row align-items-center justify-content-center">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading bold lh-15 fs-13">{{bank.reference ? bank.reference + ' - ':''}}{{bank.holder_name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-13 muted"><b class="m-r-5 text-primary">{{bank.account_no}}</b> {{bank.bank_name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0" v-show="!createBank && account_no">
|
||||
<button class="btn btn-sm h-100 btn-primary b-rad-none all-caps" @click="createBank = !createBank; dropdownStatus = false">
|
||||
<i class="fa fa-plus m-r-5"></i>
|
||||
Create New
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-show="createBank || isEditing">
|
||||
<div class="col">
|
||||
<bank-account-form-component v-if="data.serviceType.id !== 4" section="bookingEditRecipientDetailSection" :data="Object.keys(parameters.bankAccount).length ? parameters.bankAccount : {account_no: account_no, company_id: data.company.id, country_id: 2, account_type: 2}" :company_id="data.company.id" :country_id="2" :type="2" :currency="data.serviceType.selectedCurrency.short_code" v-on:createdBank="updateBank($event)" v-on:updatedBankDetails="updatedBankDetails($event)" :serviceType="data.serviceType" :closable=false v-on:close="clearAccount()" :isEditing="isEditing"></bank-account-form-component>
|
||||
<phone-account-form-component v-if="data.serviceType.id === 4" section="bookingEditRecipientDetailSection" :data="Object.keys(parameters.bankAccount).length ? parameters.bankAccount : {account_no: account_no, company_id: data.company.id, country_id: 2, account_type: 2}" :company_id="data.company.id" :country_id="2" :type="2" v-on:createdBank="updateBank($event)" v-on:updatedBankDetails="updatedBankDetails($event)" :serviceType="data.serviceType" :closable=false v-on:close="clearAccount()" :isEditing="isEditing"></phone-account-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<update-booking-component section="bookingEditRecipientDetailSection" :data="data" v-if="parameters" v-on:updatedBooking="updatedBankDetails($event)" v-on:updateBookingCanceled="cancelUpdate()"></update-booking-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FormHandler from '../../../general/mixins/formHandler';
|
||||
import UpdateBookingComponent from "../forms/UpdateBookingComponent";
|
||||
export default {
|
||||
components: {UpdateBookingComponent},
|
||||
data(){
|
||||
return {
|
||||
createBank: false,
|
||||
isEditing: true,
|
||||
recipientBanks: [],
|
||||
dropdownStatus: false,
|
||||
account_no: '',
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.recipientBanks = this.data.recipientBanks;
|
||||
},
|
||||
methods: {
|
||||
AccountNumber(bank){
|
||||
return bank.account_no.startsWith(this.account_no)
|
||||
},
|
||||
updateBank(bank){
|
||||
this.selectBank(bank);
|
||||
this.recipientBanks.push(bank);
|
||||
this.parameters.bankAccount = bank;
|
||||
this.parameters.bankAccountDefault = bank;
|
||||
},
|
||||
updatedBankDetails(bank){
|
||||
this.parameters.bankAccount = bank;
|
||||
this.parameters.bankAccountDefault = bank;
|
||||
|
||||
var foundIndex = this.recipientBanks.findIndex(x => x.id == bank.id);
|
||||
this.recipientBanks[foundIndex] = bank;
|
||||
|
||||
this.$emit('updatedBankDetails', bank);
|
||||
},
|
||||
selectBank(bank){
|
||||
this.account_no = bank.account_no;
|
||||
this.isEditing = true;
|
||||
this.createBank = false;
|
||||
this.parameters.bankAccount = bank;
|
||||
this.dropdownStatus = false;
|
||||
},
|
||||
clearAccount(){
|
||||
this.createBank = false;
|
||||
this.isEditing = false;
|
||||
this.account_no = '';
|
||||
},
|
||||
cancelUpdate(){
|
||||
this.parameters.bankAccount = this.parameters.bankAccountDefault;
|
||||
this.isEditing = true;
|
||||
this.createBank = false;
|
||||
}
|
||||
},
|
||||
mixins: [FormHandler]
|
||||
}
|
||||
</script>
|
||||
+28
-5
@@ -81,6 +81,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<div class="btn btn-sm btn-block b-rad-none shadow-sm pointer requestModal" data-type="transferSummary" id="transfer-now" name="transfer-now">EDIT</div>
|
||||
</div>
|
||||
<modal-component id="select-account-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="transferSummary" size="large">
|
||||
<booking-recipient-edit-component :data="recipientBanks" :section="section" v-on:updatedBankDetails="updatedBankDetails($event)"></booking-recipient-edit-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -540,12 +548,26 @@
|
||||
id: '',
|
||||
status: false
|
||||
},
|
||||
onlinePayment: {
|
||||
onlinePayment: {
|
||||
id: '',
|
||||
status: false
|
||||
},
|
||||
amount: (Math.round((this.data.outstanding_amount + Number.EPSILON) * 100) / 100).toFixed(2),
|
||||
calculation: null
|
||||
calculation: null,
|
||||
recipientBanks: {
|
||||
company: this.data.company,
|
||||
serviceType: {
|
||||
status: false,
|
||||
id: this.data.service.id,
|
||||
name: this.data.service.name,
|
||||
currencies: this.data.service.configurations.currencies,
|
||||
selectedCurrency: this.data.service.configurations.currencies[0]
|
||||
},
|
||||
bankAccount: this.data.bank,
|
||||
bankAccountDefault: this.data.bank,
|
||||
recipientBanks: this.data.company.recipient_banks.accounts,
|
||||
bookingId: this.data.id
|
||||
}
|
||||
}
|
||||
},
|
||||
validations () {
|
||||
@@ -575,14 +597,12 @@
|
||||
id: bankCode,
|
||||
status: true,
|
||||
}
|
||||
|
||||
},
|
||||
submitForm(){
|
||||
this.parameters = {
|
||||
payment_method: this.paymentMethod.id,
|
||||
amount: this.amount
|
||||
};
|
||||
|
||||
this.submit(route('api.booking.payment.quotation', this.item.id), 'post', this.section, false, false)
|
||||
this.calculation = null;
|
||||
},
|
||||
@@ -600,9 +620,12 @@
|
||||
cancelQuotation(){
|
||||
this.calculation = null;
|
||||
this.expandPayment = false;
|
||||
},
|
||||
updatedBankDetails(bank){
|
||||
this.item.bank = bank;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler],
|
||||
directives: {money: VMoney}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-auto" v-show="!isLoading">
|
||||
<button id="cancel-new-booking" name="cancel-new-booking" class="btn btn-lg btn-default bg-master-lightest b-rad-none all-caps fs-12" data-dismiss="modal" @click="cancelUpdateBooking()">Cancel</button>
|
||||
</div>
|
||||
<div class="col text-right" v-show="!isLoading">
|
||||
<button id="confirm-new-booking" name="confirm-new-booking" class="btn btn-lg btn-success b-rad-none all-caps fs-12" v-if="Object.keys(data.bankAccount).length" @click="submitForm()">SET SELECTED AS RECIPIENT AND CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
parameters: {},
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
this.isLoading = true;
|
||||
this.parameters = {
|
||||
transferable_bank_id: this.data.bankAccount.id,
|
||||
};
|
||||
this.submit(route('api.booking.update.recipient', this.data.bookingId), 'put', this.section, true, true);
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.$emit('updatedBooking', this.data.bankAccount);
|
||||
this.formHandler();
|
||||
this.closeModal();
|
||||
},
|
||||
cancelUpdateBooking(){
|
||||
this.$emit('updateBookingCanceled');
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
+2
-1
@@ -7,6 +7,7 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
|
||||
Route::get('/list', 'ListBookingsController@list')->name('list');
|
||||
Route::post('/create', 'CreateBookingController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateBookingController@update')->name('update');
|
||||
Route::put('/recipient/update/{id}', 'UpdateBookingRecipientController@update')->name('update.recipient');
|
||||
Route::put('/cancel/{id}', 'CancelBookingController@cancel')->name('cancel');
|
||||
Route::put('/restore/{id}', 'RestoreBookingController@restore')->name('restore');
|
||||
Route::delete('/delete/{id}', 'DeleteBookingController@delete')->name('delete');
|
||||
@@ -33,4 +34,4 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
|
||||
|
||||
Route::post('{id}/proforma/create', 'CreateProformaInvoiceTransaction@create')->name('proforma.create');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user