mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
Merge branch 'dillon/34.6-jenkins-vapor' into vapor/development
This commit is contained in:
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
abstract class AbstractRule
|
||||
{
|
||||
|
||||
abstract protected function authorized(): bool;
|
||||
abstract protected function authorized($object): bool;
|
||||
|
||||
abstract protected function validators($object): bool;
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class AbstractRule
|
||||
*/
|
||||
public function passes(?DataTransferObject $object = null): bool {
|
||||
try {
|
||||
if(!$this->authorized()){
|
||||
if(!$this->authorized($object)){
|
||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ abstract class AbstractRule
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
interface KeyValueInterface
|
||||
{
|
||||
|
||||
public function attributes(): morphMany;
|
||||
public function attributesKVP(): morphMany;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\JobResult;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class ListDocumentsJob implements ShouldQueue
|
||||
{
|
||||
@@ -43,7 +42,7 @@ class ListDocumentsJob implements ShouldQueue
|
||||
$this->jobSubmissionObject->setJobCommand($rawPayload['data']['command']);
|
||||
}
|
||||
|
||||
$result = (App()->make(ListDocumentsJobProcessor::class))->execute($this->jobSubmissionObject);
|
||||
(App()->make(ListDocumentsJobProcessor::class))->execute($this->jobSubmissionObject);
|
||||
}
|
||||
|
||||
public function getJobId(){
|
||||
|
||||
@@ -41,7 +41,11 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
{
|
||||
$serviceTypeName = $this->transaction->owner->company->services()->where('id', $this->transaction->owner->service_id)->first()->name;
|
||||
$booking = $this->transaction->booking;
|
||||
$bankDetails = $this->generateBankDetails($booking->bank);
|
||||
$bank = $booking->bank; //cief todo: 66
|
||||
if($this->transaction->bank){
|
||||
$bank = $this->transaction->bank;
|
||||
}
|
||||
$bankDetails = $this->generateBankDetails($bank);
|
||||
|
||||
$data = [
|
||||
'amount' => number_format($this->transaction->amount, 2, '.', ''),
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Classes\Modules\Vouchers\Processors\Voucherify\NewCustomerToVoucherifyPr
|
||||
use App\Classes\Modules\Vouchers\Processors\CreateVoucherProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
||||
use App\Classes\Modules\Rewards\Services\CreatesUserReward;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
@@ -85,6 +86,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var ConnectCompanyToShippingCompanyModule */
|
||||
private $connectCompanyToShippingCompanyModule;
|
||||
|
||||
/** @var CreatesUserReward */
|
||||
private $createsUserReward;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -100,9 +104,10 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param CreateVoucherProcessor $createVoucherProcessor
|
||||
* @param RegisterOnShippingProcessor $registerOnShippingProcessor
|
||||
* @param ConnectCompanyToShippingCompanyModule $connectCompanyToShippingCompanyModule
|
||||
* @param CreatesUserReward $createsUserReward
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor,
|
||||
CreatesSeasonalSegment $createsSeasonalSegment, NewCustomerToVoucherifyProcessor $newCustomerToVoucherifyProcessor, CreateVoucherProcessor $createVoucherProcessor, RegisterOnShippingProcessor $registerOnShippingProcessor, ConnectCompanyToShippingCompanyModule $connectCompanyToShippingCompanyModule)
|
||||
CreatesSeasonalSegment $createsSeasonalSegment, NewCustomerToVoucherifyProcessor $newCustomerToVoucherifyProcessor, CreateVoucherProcessor $createVoucherProcessor, RegisterOnShippingProcessor $registerOnShippingProcessor, ConnectCompanyToShippingCompanyModule $connectCompanyToShippingCompanyModule, CreatesUserReward $createsUserReward)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -117,6 +122,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->createVoucherProcessor = $createVoucherProcessor;
|
||||
$this->registerOnShippingProcessor = $registerOnShippingProcessor;
|
||||
$this->connectCompanyToShippingCompanyModule = $connectCompanyToShippingCompanyModule;
|
||||
$this->createsUserReward = $createsUserReward;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +185,13 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->newCustomerToVoucherifyProcessor->execute($company->id, $user, true);
|
||||
|
||||
$this->createVoucherProcessor->execute($user, Vouchers::WELCOME_50_PERCENT_OFF);
|
||||
$voucher = $this->createVoucherProcessor->execute($user, Vouchers::WELCOME_50_PERCENT_OFF);
|
||||
if($voucher){
|
||||
$voucherCount = $user->rewards->where('voucher_id', $voucher->id)->count();
|
||||
if($voucherCount === 0){
|
||||
$this->createsUserReward->execute(null, $user, $voucher->id);
|
||||
}
|
||||
}
|
||||
|
||||
$shippingCompanyModuleId = null;
|
||||
if ($request->input('shipping_company_module_id')) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributes(), $model);
|
||||
return $this->handler($kv->attributesKVP(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class DeletesKeyValuePair extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param KeyValuePair $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(KeyValuePair $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class UpdatesKeyValuePair extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param KeyValuePair $model
|
||||
* @param KeyValuePairObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(KeyValuePair $model, KeyValuePairObject $object) {
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanResendEmailVerification extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -3,21 +3,17 @@
|
||||
namespace App\Classes\Modules\Banks\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\BankResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Banks\Services\FetchesBank;
|
||||
|
||||
use App\Classes\Modules\Banks\Standards\Rules\CanUpdateBank;
|
||||
use App\Classes\Modules\Banks\Services\UpdatesBank;
|
||||
use App\Classes\Modules\Banks\Services\CreatesOrUpdateBank;
|
||||
use App\Classes\Modules\Banks\Services\CreatesBankLog;
|
||||
|
||||
use App\Classes\Modules\Banks\Processors\UpdateBankProcessor;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class UpdateBankLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -44,24 +40,36 @@ class UpdateBankLogic extends AbstractControllerLogic
|
||||
/** @var CreatesBankLog */
|
||||
private $createsBankLog;
|
||||
|
||||
/** @var CreatesOrUpdateBank */
|
||||
private $createsOrUpdateBank;
|
||||
|
||||
/** @var UpdateBankProcessor */
|
||||
private $updateBankProcessor;
|
||||
|
||||
/**
|
||||
* UpdateBankLogic constructor.
|
||||
* @param CanUpdateBank $canUpdateBank
|
||||
* @param UpdatesBank $updatesBank
|
||||
* @param FetchesBank $fetchesBank
|
||||
* @param CreatesBankLog $createsBankLog
|
||||
* @param CreatesOrUpdateBank $createsOrUpdateBank
|
||||
* @param UpdateBankProcessor $updateBankProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBank $canUpdateBank,
|
||||
UpdatesBank $updatesBank,
|
||||
FetchesBank $fetchesBank,
|
||||
CreatesBankLog $createsBankLog
|
||||
CreatesBankLog $createsBankLog,
|
||||
CreatesOrUpdateBank $createsOrUpdateBank,
|
||||
UpdateBankProcessor $updateBankProcessor
|
||||
)
|
||||
{
|
||||
$this->canUpdateBank = $canUpdateBank;
|
||||
$this->updatesBank = $updatesBank;
|
||||
$this->fetchesBank = $fetchesBank;
|
||||
$this->createsBankLog = $createsBankLog;
|
||||
$this->createsOrUpdateBank = $createsOrUpdateBank;
|
||||
$this->updateBankProcessor = $updateBankProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,15 +82,15 @@ class UpdateBankLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$bankObject = new BankObject(
|
||||
$request->input('company_id'),
|
||||
$request->input('company_id'),
|
||||
$request->input('account_type'),
|
||||
$request->input('bank_name'),
|
||||
$request->input('holder_name'),
|
||||
$request->input('holder_name'),
|
||||
$request->input('account_no'),
|
||||
$request->input('bank_branch'),
|
||||
$request->input('swift'),
|
||||
$request->input('bank_branch'),
|
||||
$request->input('swift'),
|
||||
$request->input('snap'),
|
||||
$request->input('country_id'),
|
||||
$request->input('country_id'),
|
||||
$request->input('reference')
|
||||
);
|
||||
|
||||
@@ -90,12 +98,10 @@ class UpdateBankLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canUpdateBank->passes($bankObject);
|
||||
|
||||
$bank_query = $this->updatesBank->execute($bank, $bankObject);
|
||||
|
||||
// $bankLog = $this->createsBankLog->execute($bank_query);
|
||||
$bank_query = $this->updateBankProcessor->execute($bankObject, $bank, $request->input('bill_no') ?? '', (int) $request->input('transaction_id') ?? 0 );
|
||||
|
||||
return $this->resourceResponse(new BankResource($bank_query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Banks\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Banks\Standards\Rules\CanUpdateBankMetadata;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankMetadataObject;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateBankMetadataLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Bank Metadata',
|
||||
'message' => 'You have successfully updated the Bank metadata'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateBankMetadata */
|
||||
private $canUpdateBankMetadata;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/**
|
||||
* UpdateBankMetadataLogic constructor.
|
||||
* @param CanUpdateBankMetadata $canUpdateBankMetadata
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBankMetadata $canUpdateBankMetadata,
|
||||
FetchesTransaction $fetchesTransaction
|
||||
)
|
||||
{
|
||||
$this->canUpdateBankMetadata = $canUpdateBankMetadata;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$bankMetadataObject = new BankMetadataObject(
|
||||
$request->input('transactionId'),
|
||||
);
|
||||
|
||||
$this->canUpdateBankMetadata->passes($bankMetadataObject);
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->input('transactionId')]);
|
||||
$transaction->attributesKVP()->delete();
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Banks\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class BankMetadataObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $transaction_id;
|
||||
|
||||
/**
|
||||
* BankMetadataObject constructor.
|
||||
* @param int $transaction_id
|
||||
*/
|
||||
public function __construct(int $transaction_id)
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransactionId(): int
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Banks\Processors;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
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 Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Bank;
|
||||
|
||||
|
||||
class UpdateBankProcessor
|
||||
{
|
||||
/** @var UpdatesBank */
|
||||
private $updatesBank;
|
||||
|
||||
/** @var CreatesOrUpdateBank */
|
||||
private $createsOrUpdateBank;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/**
|
||||
* UpdateBankProcessor constructor.
|
||||
* @param UpdatesBank $updatesBank
|
||||
* @param CreatesOrUpdateBank $createsOrUpdateBank
|
||||
* @param CreatesKeyValuePair $createsKeyValuePair
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatesBank $updatesBank,
|
||||
CreatesOrUpdateBank $createsOrUpdateBank,
|
||||
CreatesKeyValuePair $createsKeyValuePair,
|
||||
FetchesTransaction $fetchesTransaction
|
||||
)
|
||||
{
|
||||
$this->updatesBank = $updatesBank;
|
||||
$this->createsOrUpdateBank = $createsOrUpdateBank;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BankObject $bankObject
|
||||
* @param Bank $bank
|
||||
* @param string $billNo
|
||||
* @param int $transactionId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\JobResourceNotFoundException
|
||||
*/
|
||||
public function execute(BankObject $bankObject, Bank $bank, string $billNo, int $transactionId) {
|
||||
$result = null;
|
||||
if($billNo && $transactionId){
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $transactionId]);
|
||||
//If payment transaction do not have a bank yet, create one
|
||||
if(!$transaction->bank){
|
||||
$result = $this->createsOrUpdateBank->execute($bankObject);
|
||||
|
||||
// if ($result->wasRecentlyCreated) {
|
||||
//Key #1 for Bank
|
||||
$kvp = $bank->attributesKVP()->where('key', 'App\Models\Bank')->where('value', $result->id)->latest()->first();
|
||||
if(!$kvp){
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"App\Models\Bank",
|
||||
$result->id
|
||||
);
|
||||
$this->createsKeyValuePair->execute($bank, $keyValuePairObject);
|
||||
}
|
||||
|
||||
//Key #2 for Payment Transaction (owner type: booking)
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"App\Models\Bank",
|
||||
$result->id
|
||||
);
|
||||
$this->createsKeyValuePair->execute($transaction, $keyValuePairObject);
|
||||
// }
|
||||
|
||||
}
|
||||
else{
|
||||
$result = $this->updatesBank->execute($transaction->bank, $bankObject);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$result = $this->updatesBank->execute($bank, $bankObject);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Banks\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankObject;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Bank;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CreatesOrUpdateBank extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param BankObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(BankObject $object)
|
||||
{
|
||||
$user = Auth::user(); /** @var User $user */
|
||||
$attributes = [
|
||||
'company_id' => $object->getCompanyId(),
|
||||
'account_no' => $object->getAccountNo(),
|
||||
'reference' => $object->getReference(),
|
||||
'bank_name' => $object->getBankName(),
|
||||
'holder_name' => $object->getHolderName(),
|
||||
'bank_branch' => $object->getBankBranch(),
|
||||
'type' => $object->getType(),
|
||||
'country_id' => $object->getCountryId(),
|
||||
'created_by' => Auth::id(),
|
||||
'creator_type' => in_array($user->type, RoleTypes::ADMIN_ROLES) ? RoleTypes::ADMIN : RoleTypes::USER,
|
||||
];
|
||||
|
||||
$values = [
|
||||
'swift' => $object->getSwift(),
|
||||
'snap' => $object->getSnap(),
|
||||
];
|
||||
|
||||
$model = Bank::updateOrCreate($attributes, $values); //Bank::firstOrCreate($attributes, $values);
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Banks\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankMetadataObject;
|
||||
use App\Classes\Modules\Banks\Standards\Validators\BankMetadataValidation;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CanUpdateBankMetadata extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var BankMetadataValidation */
|
||||
private $validation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateBankMetadata constructor.
|
||||
* @param BankMetadataValidation $validation
|
||||
*/
|
||||
public function __construct(BankMetadataValidation $validation)
|
||||
{
|
||||
$this->validation = $validation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
//cief todo: 66 - temporary workaround
|
||||
// if (!Auth::user()->can('update bank_metadata')) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return true;
|
||||
|
||||
if (in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BankMetadataObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->validation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BankMetadataObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Banks\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Banks\DataTransferObjects\BankMetadataObject;
|
||||
|
||||
class BankMetadataValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param BankMetadataObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'transaction_id' => $object->getTransactionId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'transaction_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
@@ -15,6 +16,7 @@ use App\Classes\Modules\Bookings\Services\GeneratesBookingMarking;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\BookingToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Milestones\Processors\CheckMilestonesForRewardProcessor;
|
||||
use App\Classes\ValueObjects\Constants\BookingAttributeNames;
|
||||
use App\Classes\ValueObjects\Constants\Milestones;
|
||||
use App\Http\Resources\BookingResource;
|
||||
|
||||
@@ -84,6 +86,21 @@ class CreateBookingLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
if (in_array($request->input('service_id'), [4, 10])) {
|
||||
if (!$request['order_reference_no']) {
|
||||
throw new MalformedRequestException('At least 1 order reference required.');
|
||||
}
|
||||
|
||||
if ($request['order_reference_no']) {
|
||||
foreach ($request['order_reference_no'] as $index => $reference) {
|
||||
if (!$reference) {
|
||||
$index += 1;
|
||||
throw new MalformedRequestException("Order reference {$index} cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$object = new BookingObject($request->input('service_id'), $request->input('transferable_bank_id'), $this->generatesBookingMarking->execute(), number_format( floatval(str_replace(',', '', $request->input('fix_amount'))), 5, '.', ''), $request->input('type') === 1 ? $request->input('convertible_currency_id') : 1, $request->input('convertible_currency_id'), 1);
|
||||
@@ -97,6 +114,15 @@ class CreateBookingLogic extends AbstractControllerLogic
|
||||
$this->bookingToPerfexCRMProcessor->execute($booking);
|
||||
}
|
||||
|
||||
if (in_array($request->input('service_id'), [4, 10])) {
|
||||
foreach ($request['order_reference_no'] as $order_reference) {
|
||||
$booking->modelAttributes()->create([
|
||||
'name' => BookingAttributeNames::ORDER_REFERENCE_NO,
|
||||
'value' => $order_reference
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//cief todo: case study 5 voucherify
|
||||
// $user = $company->employees()->first();
|
||||
// $this->checkMilestonesForRewardProcessor->execute($user, [Milestones::MILESTONE_5]);
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateRefundTransactionStatusLogic;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
@@ -100,21 +101,58 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
|
||||
$refund = $transaction->transactions()->refunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->sum('original_amount');
|
||||
|
||||
$refundInPending = $transaction->transactions()->refunds()->where('status', ApprovalStatus::PENDING_VERIFICATION)->sum('original_amount');
|
||||
|
||||
if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.');
|
||||
|
||||
// $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount'));
|
||||
// $transactionRefundCalculationObject->init();
|
||||
|
||||
$refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7);
|
||||
// refund service charges if is fully refund
|
||||
$isFullyRefund = ($refund + $request->input('amount')) == $transaction->original_amount;
|
||||
$refundTotal = $isFullyRefund ? $refundAmount + $transaction->service_charge + $transaction->tax : $refundAmount;
|
||||
if ((float)$request->input('amount') === (float)$transaction->original_amount) {
|
||||
$refundAmount = $transaction->original_amount / $transaction->currency_rate;
|
||||
$service_charges_to_refund = $transaction->service_charge;
|
||||
} else {
|
||||
$refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7);
|
||||
|
||||
$bookingAmountBeforeCurrentRefund = $booking->fix_amount - $refundInPending;
|
||||
|
||||
$bookingAmountAfterRefunded = $booking->fix_amount - $refundInPending - $request->input('amount');
|
||||
|
||||
$isFullyRefund = ($refund + $request->input('amount')) == $transaction->original_amount;
|
||||
|
||||
$voucherCode = null;
|
||||
$redemptionId = null;
|
||||
|
||||
if ($transaction->voucherRedemption) {
|
||||
// $voucherCode = $transaction->voucherRedemption->voucher->code;
|
||||
$redemptionId = $transaction->voucherRedemption->redemption_id;
|
||||
}
|
||||
|
||||
$conversionObjectBeforeCurrentRefund = new CurrencyConversionObject($bookingAmountBeforeCurrentRefund, $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, $transaction->payment_method);
|
||||
|
||||
$conversionObjectAfterRefund = new CurrencyConversionObject($isFullyRefund ? $request->input('amount') : $bookingAmountAfterRefunded, $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, $transaction->payment_method);
|
||||
|
||||
$quotationBeforeCurrentRefund = $this->fetchBookingQuotation->execute($booking->company, $conversionObjectBeforeCurrentRefund, $voucherCode, $redemptionId);
|
||||
|
||||
$quotationAfterRefund = $this->fetchBookingQuotation->execute($booking->company, $conversionObjectAfterRefund, $voucherCode, $redemptionId);
|
||||
|
||||
$service_charges_to_refund = $isFullyRefund ? $quotationBeforeCurrentRefund->getServiceCharge() : $quotationBeforeCurrentRefund->getServiceCharge() - $quotationAfterRefund->getServiceCharge();
|
||||
}
|
||||
|
||||
// refund service charges if booking is not E2E
|
||||
$refundTotal = $refundAmount;
|
||||
|
||||
if ($booking->service_id !== 5) {
|
||||
$refundTotal = $refundTotal + $service_charges_to_refund + $transaction->tax;
|
||||
} else {
|
||||
$service_charges_to_refund = 0;
|
||||
}
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id,
|
||||
1, PaymentMethodType::CASH,
|
||||
$refundTotal, $request->input('amount'), 1,
|
||||
$transaction->original_currency_id, $transaction->currency_rate,
|
||||
0, 0, null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no);
|
||||
0, $service_charges_to_refund, null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no);
|
||||
|
||||
$refund_transaction = $this->createsTransaction->execute($transaction, $object);
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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 Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\BookingAttributeNames;
|
||||
|
||||
class UpdateBookingOrderReferenceLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Booking Order References',
|
||||
'message' => 'You have successfully updated the Booking Order References'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
/**
|
||||
* UpdateBookingOrderReferenceLogic constructor.
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
*/
|
||||
public function __construct(FetchesBooking $fetchesBooking)
|
||||
{
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
if (!$request['order_reference_no']) {
|
||||
throw new MalformedRequestException('At least 1 order reference required.');
|
||||
}
|
||||
|
||||
if ($request['order_reference_no']) {
|
||||
foreach ($request['order_reference_no'] as $index => $reference) {
|
||||
if (!$reference) {
|
||||
$index += 1;
|
||||
throw new MalformedRequestException("Order reference {$index} cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
|
||||
$booking->modelAttributes()->delete();
|
||||
|
||||
foreach ($request['order_reference_no'] as $order_reference) {
|
||||
$booking->modelAttributes()->create([
|
||||
'name' => BookingAttributeNames::ORDER_REFERENCE_NO,
|
||||
'value' => $order_reference
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new BookingResource($booking));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,10 @@ use App\Classes\Modules\Vouchers\DataTransferObjects\ValidatedVoucherObject;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\ValidateVoucherifyVoucherObject;
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Vouchers\Services\Voucherify\ValidatesVoucherifyVoucher;
|
||||
use App\Classes\Modules\Vouchers\Services\Voucherify\FetchesVoucherifyRedemption;
|
||||
use App\Models\Company;
|
||||
use App\Models\Currency;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesBookingQuotation
|
||||
{
|
||||
@@ -26,27 +28,34 @@ class FetchesBookingQuotation
|
||||
/** @var ValidatesVoucherifyVoucher */
|
||||
private $validatesVoucherifyVoucher;
|
||||
|
||||
/** @var FetchesVoucherifyRedemption */
|
||||
private $fetchesVoucherifyRedemption;
|
||||
|
||||
/**
|
||||
* FetchesBookingQuotation constructor.
|
||||
* @param FetchesCompanyServiceSettings $fetchesCompanyServiceSettings
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
* @param ValidatesVoucherifyVoucher $validatesVoucherifyVoucher
|
||||
* @param FetchesVoucherifyRedemption $fetchesVoucherifyRedemption
|
||||
*/
|
||||
public function __construct(FetchesCompanyServiceSettings $fetchesCompanyServiceSettings, FetchesCurrency $fetchesCurrency, ValidatesVoucherifyVoucher $validatesVoucherifyVoucher)
|
||||
public function __construct(FetchesCompanyServiceSettings $fetchesCompanyServiceSettings, FetchesCurrency $fetchesCurrency, ValidatesVoucherifyVoucher $validatesVoucherifyVoucher, FetchesVoucherifyRedemption $fetchesVoucherifyRedemption)
|
||||
{
|
||||
$this->fetchesCompanyServiceSettings = $fetchesCompanyServiceSettings;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->validatesVoucherifyVoucher = $validatesVoucherifyVoucher;
|
||||
$this->fetchesVoucherifyRedemption = $fetchesVoucherifyRedemption;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param CurrencyConversionObject $conversionObject
|
||||
* @param string $voucherCode
|
||||
* @param null|string $voucherCode
|
||||
* @param null|string $redemptionId
|
||||
* @return CalculationObject
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, CurrencyConversionObject $conversionObject, ?string $voucherCode = null){
|
||||
public function execute(Company $company, CurrencyConversionObject $conversionObject, ?string $voucherCode = null, ?string $redemptionId = null){
|
||||
if($conversionObject->getAmount() <= 0) throw new MalformedRequestException('Your transfer must be greater than zero.');
|
||||
|
||||
$configurations = $this->fetchesCompanyServiceSettings->execute($company, $conversionObject);
|
||||
@@ -57,6 +66,8 @@ class FetchesBookingQuotation
|
||||
|
||||
$calculationObject = new CalculationObject($conversionObject, $configurations, null);
|
||||
|
||||
$voucher = null;
|
||||
|
||||
//Voucherify
|
||||
if($voucherCode){
|
||||
$employee = $company->employees()->first();
|
||||
@@ -68,7 +79,24 @@ class FetchesBookingQuotation
|
||||
"metadata" => $result->metadata,
|
||||
"order" => $result->order,
|
||||
];
|
||||
$validatedVoucherObject = new ValidatedVoucherObject(isset($voucher['metadata']->name) ? $voucher['metadata']->name: "", $voucher['code'], $voucher['discount']->type ?? 'AMOUNT', $voucher['order']->total_discount_amount, $voucher['order']->total_amount);
|
||||
}
|
||||
else if($redemptionId){
|
||||
$result = $this->fetchesVoucherifyRedemption->execute($redemptionId);
|
||||
$voucher = [
|
||||
"code" => $result->voucher->code ?? null,
|
||||
"discount" => null,
|
||||
"metadata" => null,
|
||||
"order" => $result->order ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
if($voucher){
|
||||
$validatedVoucherObject = new ValidatedVoucherObject(
|
||||
isset($voucher['metadata']->name) ? $voucher['metadata']->name : "",
|
||||
$voucher['code'],
|
||||
$voucher['discount']->type ?? 'AMOUNT',
|
||||
$voucher['order']->total_discount_amount,
|
||||
$voucher['order']->total_amount);
|
||||
$calculationObject = new CalculationObject($conversionObject, $configurations, $validatedVoucherObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateBooking extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanDeleteBooking extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchBooking extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanListBookings extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ class CanMergeBooking extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateBooking extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanAssignSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateIdentificationDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanDeleteCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!Auth::user()->can('add currency_rate')) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanDeleteRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanListRates extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanApproveDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateFile extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanDeleteDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListDocuments extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanRenderDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanUpdateDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanUpdateDocumentReference extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -65,8 +65,12 @@ class ExportsAnalyticBillingTransactions implements FromCollection, WithHeadings
|
||||
$bill = $transaction;
|
||||
$payment = $transaction->owner;
|
||||
$booking = $payment->owner;
|
||||
$bank = $booking->bank; //cief todo: 66
|
||||
if($payment->bank){
|
||||
$bank = $payment->bank;
|
||||
}
|
||||
$company = $booking->company;
|
||||
$ecommerce = str::contains($booking->bank->bank_name, ['浙江网商银行']);
|
||||
$ecommerce = str::contains($bank->bank_name, ['浙江网商银行']);
|
||||
|
||||
return [
|
||||
$booking->id,
|
||||
@@ -88,4 +92,4 @@ class ExportsAnalyticBillingTransactions implements FromCollection, WithHeadings
|
||||
$bill->created_at
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class CheckMilestonesForRewardProcessor
|
||||
$voucherEndDate = $result->expiration_date;
|
||||
|
||||
//create voucher
|
||||
$voucherObject = new VoucherObject($result->code, isset($voucherName) ? $voucherName : "", $voucherType, $voucherValue, $voucherStartDate, $voucherEndDate);
|
||||
$voucherObject = new VoucherObject($result->code, isset($voucherName) ? $voucherName : "", $voucherType, $voucherValue, null, $voucherStartDate, $voucherEndDate);
|
||||
$voucher = $this->createsVoucher->execute($voucherObject);
|
||||
if(!$voucher) $voucher = $this->fetchesVoucher->execute(['code' => $voucherObject->getCode()]);
|
||||
$voucherId = $voucher->id;
|
||||
|
||||
@@ -27,7 +27,7 @@ class CanAssignReward extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('edit milestone')) {
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateMilestone extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('add milestone')) {
|
||||
return false;
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanDeleteMilestone extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('delete milestone')) {
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanUpdateMilestone extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('edit milestone')) {
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,7 @@ class CanCreateReceipt extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,7 @@ class CanCreateReceiptDetail extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateRemark extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanDeleteRemark extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchRemark extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListRemarks extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateRemark extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateReward extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('add reward')) {
|
||||
return false;
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanDeleteReward extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
if (!Auth::user()->can('delete reward')) {
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateConstant extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!Auth::user()->can('add segment')) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanDeleteSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListSegments extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateConstant extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -27,7 +27,7 @@ class CanUpdateSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateServiceType extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanDeleteServiceType extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user