mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 09:53:58 +00:00
Merge branch 'dillon/110-period-lock-a' into vapor/development
This commit is contained in:
@@ -8,7 +8,7 @@ use App\Classes\Modules\Banks\Services\UpdatesBank;
|
||||
use App\Classes\Modules\Banks\Services\CreatesOrUpdateBank;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Bank;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanCreateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -6,8 +6,8 @@ use App\Classes\Modules\Bookings\Services\UpdatesBookingFixedAmount;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
@@ -7,8 +7,8 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessPaymentReportV2CommandJob;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Imports\Services\AutoCountDataImport;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanCreateBooking;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateLockLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Lock Created',
|
||||
'message' => 'You have successfully created a lock'
|
||||
];
|
||||
}
|
||||
|
||||
// /** @var CanCreateBooking */
|
||||
// private $canCreateBooking;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
/**
|
||||
* CreateLockLogic constructor.
|
||||
* @param CanCreateBooking $canCreateBooking
|
||||
* @param CreatesKeyValuePair $createsKeyValuePair
|
||||
*/
|
||||
public function __construct(CanCreateBooking $canCreateBooking, CreatesKeyValuePair $createsKeyValuePair)
|
||||
{
|
||||
// $this->canCreateBooking = $canCreateBooking;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $password = $request->input('password');
|
||||
// if($password !== 'prototype'){
|
||||
// throw new AccessForbiddenException('Incorrect Password');
|
||||
// }
|
||||
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
KVPKey::UI_SUPPLIER_PAID_CURRENCY_ORDER_TAB_IS_LOCKED,
|
||||
0
|
||||
);
|
||||
$this->createsKeyValuePair->execute(null, $keyValuePairObject);
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanFetchBooking;
|
||||
use App\Http\Resources\LockResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchLockLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Lock',
|
||||
'message' => 'You have successfully retrieved a Lock'
|
||||
];
|
||||
}
|
||||
|
||||
// /** @var CanFetchBooking */
|
||||
// private $canFetchBooking;
|
||||
|
||||
/** @var FetchesKeyValuePair */
|
||||
private $fetchesKeyValuePair;
|
||||
|
||||
/**
|
||||
* FetchLockLogic constructor.
|
||||
* @param CanFetchBooking $canFetchBooking
|
||||
* @param FetchesKeyValuePair $fetchesKeyValuePair
|
||||
*/
|
||||
public function __construct(CanFetchBooking $canFetchBooking, FetchesBooking $fetchesKeyValuePair)
|
||||
{
|
||||
// $this->canFetchBooking = $canFetchBooking;
|
||||
$this->fetchesKeyValuePair = $fetchesKeyValuePair;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $this->canFetchBooking->passes();
|
||||
|
||||
// $query = $this->fetchesKeyValuePair->execute(['marking' => $request->route('marking'), 'with_transactions' => true]);
|
||||
|
||||
// return $this->resourceResponse(new LockResource($query));
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Settings\Services\ListsKeyValuePairs;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanListServiceTypes;
|
||||
use App\Http\Resources\LockResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListLocksLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Locks',
|
||||
'message' => 'You have successfully retrieved a list of Locks'
|
||||
];
|
||||
}
|
||||
|
||||
// /** @var CanListServiceTypes */
|
||||
// private $canListServiceTypes;
|
||||
|
||||
/** @var ListsKeyValuePairs */
|
||||
private $listsKeyValuePairs;
|
||||
|
||||
/**
|
||||
* ListLocksLogic constructor.
|
||||
* @param CanListServiceTypes $canListServiceTypes
|
||||
* @param ListsKeyValuePairs $listsKeyValuePairs
|
||||
*/
|
||||
public function __construct(CanListServiceTypes $canListServiceTypes, ListsKeyValuePairs $listsKeyValuePairs)
|
||||
{
|
||||
// $this->canListServiceTypes = $canListServiceTypes;
|
||||
$this->listsKeyValuePairs = $listsKeyValuePairs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $this->canListServiceTypes->passes();
|
||||
|
||||
$query = $this->listsKeyValuePairs->execute($this->listsKeyValuePairs->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(LockResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanUpdateServiceType;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\UpdatesKeyValuePair;
|
||||
use App\Http\Resources\LockResource;
|
||||
use App\Models\KeyValuePair;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateLockLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Lock Status',
|
||||
'message' => 'You have successfully updated the Lock status'
|
||||
];
|
||||
}
|
||||
|
||||
// /** @var CanUpdateServiceType */
|
||||
// private $canUpdateServiceType;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
/** @var UpdatesKeyValuePair */
|
||||
private $updatesKeyValuePair;
|
||||
|
||||
/**
|
||||
* UpdateLockLogic constructor.
|
||||
* @param CanUpdateServiceType $canUpdateServiceType
|
||||
* @param CreatesKeyValuePair $createsKeyValuePair
|
||||
* @param UpdatesKeyValuePair $updatesKeyValuePair
|
||||
*/
|
||||
public function __construct(CanUpdateServiceType $canUpdateServiceType, CreatesKeyValuePair $createsKeyValuePair, UpdatesKeyValuePair $updatesKeyValuePair)
|
||||
{
|
||||
// $this->canUpdateServiceType = $canUpdateServiceType;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
$this->updatesKeyValuePair = $updatesKeyValuePair;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$key = $request->input('key');
|
||||
$kvp = KeyValuePair::whereNull('owner_type')
|
||||
->whereNull('owner_id')
|
||||
->where('key', $key)
|
||||
->first();
|
||||
$value = ($kvp->value === "1") ? "0" : "1";
|
||||
$this->updateOrCreateKeyValuePair($key, $value);
|
||||
return $this->resourceResponse(new LockResource($kvp));
|
||||
|
||||
}
|
||||
|
||||
private function updateOrCreateKeyValuePair($key, $value)
|
||||
{
|
||||
$keyValuePairObject = new KeyValuePairObject($key, $value);
|
||||
$kvp = KeyValuePair::whereNull('owner_type')
|
||||
->whereNull('owner_id')
|
||||
->where('key', $key)
|
||||
->first();
|
||||
|
||||
if ($kvp) {
|
||||
$this->updatesKeyValuePair->execute($kvp, $keyValuePairObject);
|
||||
} else {
|
||||
$this->createsKeyValuePair->execute(null, $keyValuePairObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
namespace App\Classes\Modules\Settings\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
@@ -17,12 +17,19 @@ class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function execute(KeyValueInterface $kv, KeyValuePairObject $object) {
|
||||
public function execute(?KeyValueInterface $kv, KeyValuePairObject $object) {
|
||||
$model = new KeyValuePair();
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributesKVP(), $model);
|
||||
// Owner-less
|
||||
if (is_null($kv)) {
|
||||
$model->owner_type = null;
|
||||
$model->owner_id = null;
|
||||
$model->save();
|
||||
return $model;
|
||||
}
|
||||
|
||||
return $this->handler($kv->attributesKVP(), $model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class FetchesKeyValuePair extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var KeyValuePair */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesKeyValuePair constructor.
|
||||
* @param KeyValuePair $repository
|
||||
*/
|
||||
public function __construct(KeyValuePair $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Settings\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\KeyValuePair;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListsKeyValuePairs extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var KeyValuePair */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* ListsKeyValuePairs constructor.
|
||||
* @param KeyValuePair $repository
|
||||
*/
|
||||
public function __construct(KeyValuePair $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
namespace App\Classes\Modules\Settings\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
@@ -16,8 +16,8 @@ use App\Classes\Modules\Vouchers\Services\CreatesVoucher;
|
||||
use App\Classes\Modules\Vouchers\Services\FetchesVoucher;
|
||||
use App\Classes\Modules\Vouchers\Services\UpdatesVoucherCampaign;
|
||||
use App\Classes\Modules\Rewards\Services\CreatesUserReward;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Vouchers\Standards\Rules\CanCreateVoucher;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\ValidateVoucherifyVoucherObject;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\CreateVoucherObject;
|
||||
|
||||
@@ -15,8 +15,8 @@ use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Settings\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Models\Transaction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user