diff --git a/app/Classes/Modules/Accounting/ControllersLogic/UpdateStatementTransactionStatusLogic.php b/app/Classes/Modules/Accounting/ControllersLogic/UpdateStatementTransactionStatusLogic.php index 296981a0..29163a0c 100644 --- a/app/Classes/Modules/Accounting/ControllersLogic/UpdateStatementTransactionStatusLogic.php +++ b/app/Classes/Modules/Accounting/ControllersLogic/UpdateStatementTransactionStatusLogic.php @@ -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)); } diff --git a/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTransactionObject.php b/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTransactionObject.php new file mode 100644 index 00000000..30bac5d3 --- /dev/null +++ b/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTransactionObject.php @@ -0,0 +1,137 @@ +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; + } +} diff --git a/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementDetailObject.php b/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTrasactionOwnerObject.php similarity index 92% rename from app/Classes/Modules/Accounting/DataTransferObjects/BankStatementDetailObject.php rename to app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTrasactionOwnerObject.php index 8da675d6..07fe876e 100644 --- a/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementDetailObject.php +++ b/app/Classes/Modules/Accounting/DataTransferObjects/BankStatementTrasactionOwnerObject.php @@ -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; diff --git a/app/Classes/Modules/Accounting/Services/FetchesStatementTransaction.php b/app/Classes/Modules/Accounting/Services/FetchesBankStatementTransaction.php similarity index 90% rename from app/Classes/Modules/Accounting/Services/FetchesStatementTransaction.php rename to app/Classes/Modules/Accounting/Services/FetchesBankStatementTransaction.php index 1ef2bdb3..d2bff6f9 100644 --- a/app/Classes/Modules/Accounting/Services/FetchesStatementTransaction.php +++ b/app/Classes/Modules/Accounting/Services/FetchesBankStatementTransaction.php @@ -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 */ diff --git a/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwner.php b/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwner.php new file mode 100644 index 00000000..6af3d3d6 --- /dev/null +++ b/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwner.php @@ -0,0 +1,32 @@ +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); + } +} diff --git a/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwnerStatus.php b/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwnerStatus.php new file mode 100644 index 00000000..abcda20a --- /dev/null +++ b/app/Classes/Modules/Accounting/Services/UpdatesBankStatementTransactionOwnerStatus.php @@ -0,0 +1,22 @@ +status = $status; + return $this->handler($model); + } +} diff --git a/routes/accounting.php b/routes/accounting.php index b59bf98f..f6b1ba8c 100644 --- a/routes/accounting.php +++ b/routes/accounting.php @@ -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'); }); });