mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-29 09:24:07 +00:00
Merge branch 'dillon/accounting-bank-mapping' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounting\Services\ListsBankStatementTransactions;
|
||||
use App\Http\Resources\BankStatementTransactionResource;
|
||||
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementTransactionOwnerStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class GroupApproveStatementTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Group Approve Statement Transaction',
|
||||
'message' => 'You have successfully approveed a group of Statement Transation'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsBankStatementTransactions */
|
||||
private $listsBankStatementTransactions;
|
||||
|
||||
/** @var UpdatesBankStatementTransactionOwnerStatus */
|
||||
private $updatesBankStatementTransactionOwnerStatus;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param ListsBankStatementTransactions $listsBankStatementTransactions
|
||||
* @param UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
*/
|
||||
public function __construct(
|
||||
ListsBankStatementTransactions $listsBankStatementTransactions,
|
||||
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
) {
|
||||
$this->listsBankStatementTransactions = $listsBankStatementTransactions;
|
||||
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$statementTrasactions = $this->listsBankStatementTransactions->execute($this->listsBankStatementTransactions->deserializeFilters(
|
||||
json_decode("{min_amount: 0, is_mapped: true, is_mapped_with_multiple: false, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [1], per_page: 100, order_by: {column: 'posting_date', DESC: true}}", true)
|
||||
));
|
||||
|
||||
foreach ($statementTrasactions as $statementTrasaction) {
|
||||
$statementTrasactionOwner = $statementTrasaction->owners;
|
||||
|
||||
if (count($statementTrasactionOwner)) {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($statementTrasactionOwner->first(), ApprovalStatus::APPROVED);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collectionResponse(BankStatementTransactionResource::collection($statementTrasactions));
|
||||
}
|
||||
}
|
||||
+19
-8
@@ -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,7 +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();
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounting;
|
||||
|
||||
use App\Classes\Modules\Accounting\ControllersLogic\GroupApproveStatementTransactionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GroupApproveStatementTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ApprovePaymentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function approve(Request $request, GroupApproveStatementTransactionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
+6
-2
@@ -69,9 +69,9 @@
|
||||
contentText="Are you sure you want to reject this mapping?"
|
||||
modalType="delete"
|
||||
class="text-center"
|
||||
:apiRoute="route('accounting.statement_transaction.owner.status.update', item.id, 'reject')"
|
||||
:apiRoute="route('api.accounting.statement_transaction.owner.status.update', item.id, 'reject')"
|
||||
apiMethod="post"
|
||||
section="statementTransactionComponent"
|
||||
:section="section"
|
||||
>
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
@@ -91,6 +91,10 @@
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
section:{
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
typeString(type){
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@
|
||||
contentText="Are you sure you want to approve all these Transaction?"
|
||||
modalType="confirm"
|
||||
class="text-center"
|
||||
:apiRoute="route('api.company.delete', 1)"
|
||||
:apiRoute="route('api.accounting.statement_transaction.owner.groupApprove')"
|
||||
apiMethod="post"
|
||||
:section="section"
|
||||
>
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
<div class="btn btn-sm btn-default btn-block bg-master-lighter" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<!-- <div class="btn btn-sm btn-block b-rad-none" :class="[{'btn-danger': modalType !== 'confirm'}, {'btn-success': modalType === 'confirm'}]" @click="submit(apiRoute, apiMethod, section, true, true)">{{ buttonText }}</div> -->
|
||||
<div class="btn btn-sm btn-block b-rad-none" :class="[{'btn-danger': modalType !== 'confirm'}, {'btn-success': modalType === 'confirm'}]" @click="test">{{ buttonText }}</div>
|
||||
<div class="btn btn-sm btn-block b-rad-none" :class="[{'btn-danger': modalType !== 'confirm'}, {'btn-success': modalType === 'confirm'}]" @click="submit(apiRoute, apiMethod, section, true, true)">{{ buttonText }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="col">
|
||||
<list-component ref="paymentProofList" section="bankStatementSection" :endpoint="route('api.accounting.bank.transaction')" :options="{statement_transaction_account_id: {{$account}}, per_page: 100, order_by: {column: 'posting_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<statement-transaction-component :data="data"></statement-transaction-component>
|
||||
<statement-transaction-component section="bankStatementSection" :data="data"></statement-transaction-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@section('inner_content')
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<statement-transactions-details-component :statement="{{$statement}}"></statement-transactions-details-component>
|
||||
<statement-transactions-details-component section="bankStatementDetail" :statement="{{$statement}}"></statement-transactions-details-component>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -307,7 +307,7 @@
|
||||
<div class="col">
|
||||
<list-component ref="exceptionalBankTransactionsList" section="exceptionalBankTransactionSection" :endpoint="route('api.accounting.bank.transaction')" :options="{is_mapped: true, statement_transaction_owner_type_in: [6, 7, 8, 9, 10, 11, 12, 13, 14], per_page: 100, order_by: {column: 'posting_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<statement-transaction-component :data="data"></statement-transaction-component>
|
||||
<statement-transaction-component section="exceptionalBankTransactionSection" :data="data"></statement-transaction-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ 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('/owner/group-approve', 'GroupApproveStatementTransactionController@approve')->name('owner.groupApprove');
|
||||
Route::post('/{id}/owner/{status}', 'UpdateStatementTransactionStatusController@update')->where('status', 'approve|reject')->name('owner.status.update');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user