mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
EXCHANGE-149 - Layout, components for merge bookings (abit on backend for filter booking list)
This commit is contained in:
+12
-1
@@ -13,4 +13,15 @@ npm-debug.log
|
||||
yarn-error.log
|
||||
/storage/file
|
||||
composer.lock
|
||||
yarn.lock
|
||||
yarn.lock
|
||||
.DS_Store
|
||||
public/.DS_Store
|
||||
public/images/.DS_Store
|
||||
gox.iml
|
||||
rebuild_docker.sh
|
||||
docker/*
|
||||
db/*
|
||||
docker-compose.yml
|
||||
package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ConvertibleCurrencyId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('convertible_currency_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class FixedCurrencyId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('fix_currency_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class IdIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingMergeObject;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanMergeBooking;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Banks\Services\FetchesBank;
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanCreateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\CreatesBooking;
|
||||
use App\Classes\Modules\Bookings\Services\GeneratesBookingMarking;
|
||||
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\BookingResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MergeBookingLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Merge Booking',
|
||||
'message' => 'You have successfully merged Booking'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateBooking */
|
||||
private $canMergeBooking;
|
||||
|
||||
/** @var CreatesBooking */
|
||||
private $createsBooking;
|
||||
|
||||
/** @var GeneratesBookingMarking */
|
||||
private $generatesBookingMarking;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesBooking;
|
||||
|
||||
/**
|
||||
* CreateBookingLogic constructor.
|
||||
* @param CanMergeBooking $canMergeBooking
|
||||
* @param CreatesBooking $createsBooking
|
||||
* @param GeneratesBookingMarking $generatesBookingMarking
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(CanMergeBooking $canMergeBooking, CreatesBooking $createsBooking, GeneratesBookingMarking $generatesBookingMarking, FetchesCompany $fetchesCompany, FetchesBooking $fetchesBooking)
|
||||
{
|
||||
$this->canMergeBooking = $canMergeBooking;
|
||||
$this->createsBooking = $createsBooking;
|
||||
$this->generatesBookingMarking = $generatesBookingMarking;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\ResourceNotFoundException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new BookingMergeObject($request->get('booking_ids'));
|
||||
|
||||
$this->canMergeBooking->passes($object);
|
||||
|
||||
/*
|
||||
$bookings = $this->fetchesBooking->execute([
|
||||
'id_in'=> $object->getBookingIds(),
|
||||
'status' => ApprovalStatus::APPROVED,
|
||||
]);
|
||||
*/
|
||||
#TODO: Fetch transaction (+details) record, reassign transaction id & recalculate amount
|
||||
|
||||
//dd($bookings);
|
||||
|
||||
return $this->response();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class BookingMergeObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $bookingIds;
|
||||
|
||||
/**
|
||||
* BookingMergeObject constructor.
|
||||
* @param array $bookingIds
|
||||
*/
|
||||
public function __construct(array $bookingIds)
|
||||
{
|
||||
$this->bookingIds = $bookingIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBookingIds(): array
|
||||
{
|
||||
return $this->bookingIds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\Modules\Bookings\Standards\Validators\BookingMergeValidation;
|
||||
|
||||
class CanMergeBooking extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var BookingMergeValidation */
|
||||
private $bookingMergeValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanCreateBooking constructor.
|
||||
* @param BookingMergeValidation $bookingMergeValidation
|
||||
*/
|
||||
public function __construct(BookingMergeValidation $bookingMergeValidation)
|
||||
{
|
||||
$this->bookingMergeValidation = $bookingMergeValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->bookingMergeValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingMergeObject;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
|
||||
class BookingMergeValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param BookingMergeObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'booking_ids' => $object->getBookingIds()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'booking_ids' => 'required|array|min:2',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\MergeBookingLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MergeBookingController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param MergeBookingLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function merge(Request $request, MergeBookingLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="row align-items-center m-b-15 parentContainer">
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-12">
|
||||
<input type="checkbox" v-bind:data-id="this.item.id" @change="selectedBookings">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col-auto p-r-10 all-caps">
|
||||
<div class="font-heading all-caps fs-11 bold">{{this.item.marking}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-10 muted">{{this.item.created_at}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col" v-if="$store.getters.isAdmin">
|
||||
<div class="font-heading fs-10 muted all-caps">Marking</div>
|
||||
<div class="font-heading fs-12">
|
||||
{{this.item.company.reference}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Currency</div>
|
||||
<div class="font-heading fs-12 bold">
|
||||
<span class="flag-icon fs-12" :class="'flag-icon-'+item.convertible_currency.country.short_code.toLowerCase()"></span> {{this.item.convertible_currency.short_code}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Transfer Type</div>
|
||||
<div class="font-heading fs-11">{{this.item.service.name}}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Payable Amount</div>
|
||||
<div class="font-heading fs-11 text-success bold">{{this.item.amount}} {{this.item.fixed_currency.short_code}}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Status</div>
|
||||
<div class="font-heading fs-11 text-success bold">{{this.item.status}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
methods: {
|
||||
selectedBookings(e) {
|
||||
this.$root.$emit('selectedBookings', e.target);
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<booking-merge-section-component :marking={{$marking}}></booking-merge-section-component>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -6,6 +6,7 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
|
||||
Route::get('/show/{marking}', 'FetchBookingController@fetch')->name('show');
|
||||
Route::get('/list', 'ListBookingsController@list')->name('list');
|
||||
Route::post('/create', 'CreateBookingController@create')->name('create');
|
||||
Route::post('/merge', 'MergeBookingController@merge')->name('merge');
|
||||
Route::put('/update/{id}', 'UpdateBookingController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteBookingController@delete')->name('delete');
|
||||
|
||||
|
||||
+3
-1
@@ -37,4 +37,6 @@ Route::get('/transfer/{marking}', function ($marking) {
|
||||
return view('pages.booking_details', ['marking' => $marking]);
|
||||
})->name('booking.details');
|
||||
|
||||
|
||||
Route::get('/transfer/merge/{marking}', function ($marking) {
|
||||
return view('pages.booking_merge', ['marking' => $marking]);
|
||||
})->name('booking.merge');
|
||||
|
||||
Reference in New Issue
Block a user