mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
reject statement transaction mapping api
This commit is contained in:
+16
-9
@@ -3,9 +3,10 @@
|
||||
namespace App\Classes\Modules\Accounting\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounting\Services\FetchesStatementTransaction;
|
||||
use App\Classes\Modules\Accounting\Services\FetchesBankStatementTransaction;
|
||||
use App\Http\Resources\BankStatementTransactionResource;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementTransactionOwnerStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -24,17 +25,23 @@ class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesStatementTransaction */
|
||||
private $fetchesStatementTransaction;
|
||||
/** @var FetchesBankStatementTransaction */
|
||||
private $fetchesBankStatementTransaction;
|
||||
|
||||
/** @var UpdatesBankStatementTransactionOwnerStatus */
|
||||
private $updatesBankStatementTransactionOwnerStatus;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param FetchesStatementTransaction $fetchesStatementTransaction
|
||||
* @param FetchesBankStatementTransaction $fetchesBankStatementTransaction
|
||||
* @param UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesStatementTransaction $fetchesStatementTransaction
|
||||
FetchesBankStatementTransaction $fetchesBankStatementTransaction,
|
||||
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
) {
|
||||
$this->fetchesStatementTransaction = $fetchesStatementTransaction;
|
||||
$this->fetchesBankStatementTransaction = $fetchesBankStatementTransaction;
|
||||
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,11 +53,11 @@ class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$statementTrasaction = $this->fetchesStatementTransaction->execute(['id' => $request->route('id')]);
|
||||
$statementTrasaction = $this->fetchesBankStatementTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$statementTrasactionOwner = $statementTrasaction->owners->first();
|
||||
|
||||
dd($statementTrasactionOwner);
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($statementTrasactionOwner, $request->route('status') == 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
return $this->resourceResponse(new BankStatementTransactionResource($statementTrasaction));
|
||||
}
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
|
||||
|
||||
class BankStatementTransactionObject implements DataTransferObject
|
||||
{
|
||||
/** @var int */
|
||||
private $statement_transaction_id;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var string */
|
||||
private $system;
|
||||
|
||||
/** @var string */
|
||||
private $owner_type;
|
||||
|
||||
/** @var int */
|
||||
private $owner_id;
|
||||
|
||||
/** @var string */
|
||||
private $invoice_reference;
|
||||
|
||||
/** @var string */
|
||||
private $receipt_reference;
|
||||
|
||||
/** @var Boolean */
|
||||
private $is_auto_mapped;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* BankStatementDetailObject constructor.
|
||||
* @param string $pay_for
|
||||
* @param string $system_references
|
||||
* @param int|null $type
|
||||
*/
|
||||
public function __construct(
|
||||
$statement_transaction_id,
|
||||
$type,
|
||||
$system,
|
||||
$owner_type,
|
||||
$owner_id,
|
||||
$invoice_reference,
|
||||
$receipt_reference,
|
||||
$is_auto_mapped,
|
||||
?int $status = ApprovalStatus::PENDING_VERIFICATION
|
||||
) {
|
||||
$this->statement_transaction_id = $statement_transaction_id;
|
||||
$this->type = $type;
|
||||
$this->system = $system;
|
||||
$this->owner_type = $owner_type;
|
||||
$this->owner_id = $owner_id;
|
||||
$this->invoice_reference = $invoice_reference;
|
||||
$this->receipt_reference = $receipt_reference;
|
||||
$this->is_auto_mapped = $is_auto_mapped;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatementTransactionId(): int
|
||||
{
|
||||
return $this->statement_transaction_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOwnerType(): string
|
||||
{
|
||||
return $this->owner_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOwnerId(): int
|
||||
{
|
||||
return $this->owner_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSystem(): string
|
||||
{
|
||||
return $this->system;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInvoiceReference(): string
|
||||
{
|
||||
return $this->invoice_reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReceipteReference(): string
|
||||
{
|
||||
return $this->receipt_reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Boolean
|
||||
*/
|
||||
public function getIsAutoMapped(): Boolean
|
||||
{
|
||||
return $this->is_auto_mapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounting\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class BankStatementDetailObject implements DataTransferObject
|
||||
class BankStatementTrasactionOwnerObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $pay_for;
|
||||
+1
-1
@@ -7,7 +7,7 @@ use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\StatementTransaction;
|
||||
|
||||
class FetchesStatementTransaction extends AbstractFetchRecord
|
||||
class FetchesBankStatementTransaction extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var StatementTransaction */
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounting\DataTransferObjects\BankStatementTransactionObject;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
|
||||
class UpdatesBankStatementTransactionOwner extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param StatementTransactionOwner $model
|
||||
* @param BankStatementDetailsObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(StatementTransactionOwner $model, BankStatementTransactionObject $object)
|
||||
{
|
||||
$model->statement_transaction_id = $object->getStatementTransactionId();
|
||||
$model->type = $object->getType();
|
||||
$model->system = $object->getSystem();
|
||||
$model->owner_type = $object->getOwnerType();
|
||||
$model->owner_id = $object->getOwnerId();
|
||||
$model->invoice_reference = $object->getInvoiceReference();
|
||||
$model->receipt_reference = $object->getReceipteReference();
|
||||
$model->is_auto_mapped = $object->getIsAutoMapped();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
|
||||
class UpdatesBankStatementTransactionOwnerStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param StatementTransactionOwner $model
|
||||
* @param BankStatementDetailsObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(StatementTransactionOwner $model, int $status)
|
||||
{
|
||||
$model->status = $status;
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,6 @@ Route::group(['prefix' => 'accounting', 'as' => 'accounting.', 'namespace' => 'A
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'statement_transaction', 'as' => 'statement_transaction.'], function () {
|
||||
Route::post('/{id}/owner/{status}', 'UpdateStatementTransactionStatusController@update')->name('owner.status.update');
|
||||
Route::post('/{id}/owner/{status}', 'UpdateStatementTransactionStatusController@update')->where('status', 'approve|reject')->name('owner.status.update');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user