mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 23:13:59 +00:00
add edit at pending_export
This commit is contained in:
@@ -19,6 +19,9 @@ use App\Models\Wallet;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementTransactionOwnerStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
|
||||
class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -40,14 +43,21 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
/** @var ChecksBillNumber */
|
||||
private $checksBillNumber;
|
||||
|
||||
/** @var UpdatesBankStatementTransactionOwnerStatus */
|
||||
private $updatesBankStatementTransactionOwnerStatus;
|
||||
|
||||
/**
|
||||
* @param FetchesBankStatementTransaction $fetchesBankStatementTransaction
|
||||
* @param ChecksBillNumber $checksBillNumber
|
||||
*/
|
||||
public function __construct(FetchesBankStatementTransaction $fetchesBankStatementTransaction, ChecksBillNumber $checksBillNumber)
|
||||
public function __construct(
|
||||
FetchesBankStatementTransaction $fetchesBankStatementTransaction,
|
||||
ChecksBillNumber $checksBillNumber,
|
||||
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus)
|
||||
{
|
||||
$this->fetchesBankStatementTransaction = $fetchesBankStatementTransaction;
|
||||
$this->checksBillNumber = $checksBillNumber;
|
||||
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
|
||||
}
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
@@ -129,7 +139,10 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
|
||||
$system = $systemReference != null ? SystemType::SYSTEM_NAMES[$systemReference] : '';
|
||||
|
||||
$this->createBankStatementTransactionOwner($bankStatementTransaction, $statementTransactionOwnerType, $system, $owner_type, $owner_id, $owner_reference);
|
||||
$statementTransactionOwner = $this->createBankStatementTransactionOwner($bankStatementTransaction, $statementTransactionOwnerType, $system, $owner_type, $owner_id, $owner_reference);
|
||||
|
||||
// this for edit a transaction already mapped
|
||||
if ($request->has('editMapped')) $this->editAccountMapped($statementTransactionOwner);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
@@ -144,9 +157,26 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
'owner_reference' => $owner_reference,
|
||||
];
|
||||
|
||||
$bankStatementTransaction->owners()->firstOrCreate($ownerData);
|
||||
|
||||
return $bankStatementTransaction->owners()->firstOrCreate($ownerData);
|
||||
}
|
||||
|
||||
private function editAccountMapped(StatementTransactionOwner $owner){
|
||||
$this->updateOwnerStatus($owner, ApprovalStatus::APPROVED);
|
||||
|
||||
// update all other owners with the same system, owner type, and owner ID
|
||||
$this->updateOtherOwners($owner, ApprovalStatus::REJECTED);
|
||||
}
|
||||
|
||||
private function updateOwnerStatus(StatementTransactionOwner $owner, int $status)
|
||||
{
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($owner, $status);
|
||||
}
|
||||
|
||||
private function updateOtherOwners(StatementTransactionOwner $owner, int $status): void
|
||||
{
|
||||
StatementTransactionOwner::where('statement_transaction_id', $owner->statement_transaction_id)
|
||||
->where('id', '!=', $owner->id)
|
||||
->update(['status' => $status]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,13 @@
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
props:{
|
||||
editMapped: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
error: '',
|
||||
@@ -116,6 +123,8 @@
|
||||
system_references : this.system_references ? this.system_references.toLowerCase() : '',
|
||||
transaction_reference : this.transaction_reference
|
||||
};
|
||||
|
||||
if (this.editMapped) this.parameters['editMapped'] = true;
|
||||
|
||||
this.submit(this.route('api.accounting.statement.details.update', this.data.id), 'put', this.section, true, true);
|
||||
},
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="col d-flex justify-content-between">
|
||||
<a :href="item.owners.approved[0].reference_link" target="_blank">{{item.owners.approved[0].reference}}</a>
|
||||
<div v-if="stage === 4">
|
||||
<!-- revert button -->
|
||||
<button class="btn btn-xs btn-outline-danger b-rad-none m-r-5 requestModal" data-type="approveCorrectMappingTransaction">
|
||||
<i class="fa fa-times fa-fw"></i>
|
||||
</button>
|
||||
@@ -35,6 +36,15 @@
|
||||
>
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
|
||||
<!-- edit button -->
|
||||
<button class="btn btn-xs btn-outline-success b-rad-none m-r-5 requestModal" data-type="updateOwner">
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="updateOwner">
|
||||
<edit-single-item-in-list-component :data="item" :section="section" editMapped="true"></edit-single-item-in-list-component>
|
||||
</modal-component>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user