mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
update rate history
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedAtBetween implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereBetween('created_at', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CurrencyRateIdIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('currency_rate_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
+14
-9
@@ -5,14 +5,14 @@ namespace App\Classes\Modules\Currencies\ControllersLogic\History;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Currencies\Services\Rates\ListsRateLogs;
|
||||
use App\Classes\Modules\Currencies\Services\Rates\FetchesRate;
|
||||
use App\Classes\Modules\Currencies\Services\Rates\ListsRates;
|
||||
use App\Classes\Modules\Currencies\Standards\Rules\Rates\CanListRates;
|
||||
use App\Http\Resources\CurrencyRateLogResource;
|
||||
use App\Models\CurrencyRate;
|
||||
use App\Models\CurrencyRateLog;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ListCurrencyRateHistoryLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -34,19 +34,19 @@ class ListCurrencyRateHistoryLogic extends AbstractControllerLogic
|
||||
/** @var ListsRateLogs */
|
||||
private $listsRateLogs;
|
||||
|
||||
/** @var FetchesRate */
|
||||
private $fetchesRate;
|
||||
/** @var ListsRate */
|
||||
private $listsRates;
|
||||
|
||||
/**
|
||||
* ListRatesLogic constructor.
|
||||
* @param CanListRates $canListRates
|
||||
* @param ListsRates $listsRates
|
||||
*/
|
||||
public function __construct(CanListRates $canListRates, ListsRateLogs $listsRateLogs, FetchesRate $fetchesRate)
|
||||
public function __construct(CanListRates $canListRates, ListsRateLogs $listsRateLogs, listsRates $listsRates)
|
||||
{
|
||||
$this->canListRates = $canListRates;
|
||||
$this->listsRateLogs = $listsRateLogs;
|
||||
$this->fetchesRate = $fetchesRate;
|
||||
$this->listsRates = $listsRates;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,15 +64,20 @@ class ListCurrencyRateHistoryLogic extends AbstractControllerLogic
|
||||
$rate_filter['currency_id'] = $filterArray->currency_id;
|
||||
$rate_filter['service_id'] = $filterArray->service_id;
|
||||
|
||||
$currency_rate_ids = $this->fetchesRate->execute(
|
||||
$currency_rate_ids = $this->listsRates->execute(
|
||||
[
|
||||
'currency_id' => $filterArray->currency_id,
|
||||
'service_id' => $filterArray->service_id,
|
||||
]
|
||||
)->pluck('id')->toArray();
|
||||
|
||||
// todo: add in date filters
|
||||
$query = CurrencyRateLog::whereIn('currency_rate_id', $currency_rate_ids)->get();
|
||||
$query = $this->listsRateLogs->execute(
|
||||
[
|
||||
'currency_rate_id_in' => $currency_rate_ids,
|
||||
'date_start' => new Carbon($filterArray->date_from),
|
||||
'date_end' => new Carbon($filterArray->date_to),
|
||||
]
|
||||
);
|
||||
|
||||
return $this->collectionResponse(CurrencyRateLogResource::collection($query));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div class="row h-100">
|
||||
<div class="row h-100 mt-1 mb-1 m-md-0">
|
||||
<div class="col">
|
||||
<loading-component style="height: 100%; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
<!-- <loading-component style="height: 100%; top: 0;" key="1" color="success" v-show="isLoading"></loading-component> -->
|
||||
|
||||
<div class="row h-100" style="margin-left:1px; margin-right:1px;" v-if='!isLoading'>
|
||||
<div class="row h-100" style="margin-left:1px; margin-right:1px; min-height: 50px;" v-if='!isLoading'>
|
||||
<div class="col bg-primary text-white">
|
||||
<div class="row h-100 align-items-center">
|
||||
<div class="col p-l-5 p-r-20">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<choose-currency-component v-on:input="updateCurrencyId($event)"></choose-currency-component>
|
||||
</div>
|
||||
<div class="col-12 col-md">
|
||||
<choose-service-component v-on:input="updateServiceId($event)" v-on:loaded="fetchRateLogs"></choose-service-component>
|
||||
<choose-service-component v-on:input="updateServiceId($event)" v-on:loaded="isLoading=!isLoading"></choose-service-component>
|
||||
</div>
|
||||
<div class="col-12 col-md">
|
||||
<validation-wrapper-component :validator="$v.filters.date_from">
|
||||
@@ -23,8 +23,8 @@
|
||||
</div>
|
||||
<div class="row m-t-15">
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-lg btn-primary fs-11 " @click="fetchRateLogs()">Search</button>
|
||||
<button type="button" class="btn btn-lg btn-secondary fs-11" @click="resetSarch()">Reset</button>
|
||||
<button type="button" class="btn btn-lg btn-primary fs-11 " @click="fetchRateLogs" :class="[{'disabled': isLoading}]" :disabled="isLoading">Search</button>
|
||||
<!-- <button type="button" class="btn btn-lg btn-secondary fs-11" @click="resetSarch">Reset</button> -->
|
||||
</div>
|
||||
</div>
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
@@ -110,8 +110,8 @@ export default {
|
||||
},
|
||||
resetSarch() {
|
||||
var currentDate = new Date();
|
||||
this.filters.date_to = new Date(currentDate.setDate(currentDate.getDate() + 3)).toLocaleDateString();
|
||||
this.filters.date_from = new Date(currentDate.setDate(currentDate.getDate() - 6)).toLocaleDateString();
|
||||
this.filters.date_to =this.formatDate(new Date(currentDate.setDate(currentDate.getDate() + 3)));
|
||||
this.filters.date_from =this.formatDate(new Date(currentDate.setDate(currentDate.getDate() - 6)));
|
||||
},
|
||||
updateCurrencyId(id){
|
||||
this.filters.currency_id = id;
|
||||
@@ -123,6 +123,13 @@ export default {
|
||||
this.isLoading = false;
|
||||
this.rateHistory = response.payload.data;
|
||||
},
|
||||
formatDate($date) {
|
||||
let d = new Date($date);
|
||||
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
|
||||
let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(d);
|
||||
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
|
||||
return(`${da}-${mo}-${ye}`);
|
||||
},
|
||||
errorHandler(error){
|
||||
this.isLoading = false;
|
||||
this.hasError = true;
|
||||
|
||||
Reference in New Issue
Block a user