Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3536 Liquidity Check and Fund adjustment process after settlement #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 74 additions & 66 deletions packages/admin-ui/src/app/_services_and_types/participant_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,70 +28,78 @@
--------------
******/

"use strict";
"use strict";

import { IParticipant, IParticipantAccountChangeRequest, IParticipantContactInfoChangeRequest, IParticipantFundsMovement, IParticipantNetDebitCapChangeRequest, IParticipantSourceIpChangeRequest, IParticipantStatusChangeRequest } from "@mojaloop/participant-bc-public-types-lib";

export declare type ParticipantsSearchResults = {
pageSize: number;
totalPages: number;
pageIndex: number;
items: IParticipant[];
};

export declare interface IParticipantPendingApprovalCountByType {
type: string;
count: number;
}

export declare interface IParticipantPendingApprovalSummary {
totalCount: number;
countByType: IParticipantPendingApprovalCountByType[];
}

export declare interface IParticipantPendingApproval {
accountsChangeRequest: (IParticipantAccountChangeRequest & {
participantId: string;
participantName: string;
})[];
fundsMovementRequest: (IParticipantFundsMovement & {
participantId: string;
participantName: string;
})[];
ndcChangeRequests: (IParticipantNetDebitCapChangeRequest & {
participantId: string;
participantName: string;
})[];
ipChangeRequests: (IParticipantSourceIpChangeRequest & {
participantId: string;
participantName: string;
})[];
contactInfoChangeRequests: (IParticipantContactInfoChangeRequest & {
participantId: string;
participantName: string;
})[];
statusChangeRequests: (IParticipantStatusChangeRequest & {
participantId: string;
participantName: string;
})[];
}

export interface FundMovement {
matrixId: string
participantId: string
participantName: string
participantBankAccountInfo: string
bankBalance: number
settledTransferAmount: string
currencyCode: string
direction: string
updateAmount: string
settlementAccountId: string
isDuplicate: boolean
}

export declare interface IBulkApprovalResult {
reqId: string;
status: "success" | "error";
message: string;
}
import {
IParticipant,
IParticipantAccountChangeRequest,
IParticipantContactInfoChangeRequest,
IParticipantFundsMovement,
IParticipantNetDebitCapChangeRequest,
IParticipantSourceIpChangeRequest,
IParticipantStatusChangeRequest,
} from "@mojaloop/participant-bc-public-types-lib";

export declare type ParticipantsSearchResults = {
pageSize: number;
totalPages: number;
pageIndex: number;
items: IParticipant[];
};

export declare interface IParticipantPendingApprovalCountByType {
type: string;
count: number;
}

export declare interface IParticipantPendingApprovalSummary {
totalCount: number;
countByType: IParticipantPendingApprovalCountByType[];
}

export declare interface IParticipantPendingApproval {
accountsChangeRequest: (IParticipantAccountChangeRequest & {
participantId: string;
participantName: string;
})[];
fundsMovementRequest: (IParticipantFundsMovement & {
participantId: string;
participantName: string;
})[];
ndcChangeRequests: (IParticipantNetDebitCapChangeRequest & {
participantId: string;
participantName: string;
})[];
ipChangeRequests: (IParticipantSourceIpChangeRequest & {
participantId: string;
participantName: string;
})[];
contactInfoChangeRequests: (IParticipantContactInfoChangeRequest & {
participantId: string;
participantName: string;
})[];
statusChangeRequests: (IParticipantStatusChangeRequest & {
participantId: string;
participantName: string;
})[];
}

export interface FundMovement {
matrixId: string;
participantId: string;
participantName: string;
participantBankAccountInfo: string;
bankBalance: number;
settledTransferAmount: string;
currencyCode: string;
direction: string;
updateAmount: string;
settlementAccountId: string;
isDuplicate: boolean;
}

export declare interface IBulkApprovalResult {
reqId: string;
status: "success" | "error";
message: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ export class ParticipantsService {
}

submitPendingApprovals(data: IParticipantPendingApproval, requestState:ApprovalRequestState) {
const url = requestState == ApprovalRequestState.APPROVED?
const url = requestState == ApprovalRequestState.APPROVED?
`${SVC_BASEURL}/participants/pendingApprovals/approve`:
`${SVC_BASEURL}/participants/pendingApprovals/reject`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h4 class="mt-3">Pending Fund Adjustment for all Participants</h4>
<tr>
<th scope="col">
<input
[disabled]="fundAdjustments.value.length === 0"
[checked]="isFundAdjustmentSelectAll"
type="checkbox"
(change)="selectAllFundAdjustments($event)"
Expand Down Expand Up @@ -112,6 +113,7 @@ <h4 class="mt-3">Pending NDC for all Participants</h4>
<tr>
<th scope="col">
<input
[disabled]="ndcRequests.value.length === 0"
[checked]="isNDCSelectAll"
type="checkbox"
(change)="selectAllNDCRequests($event)"
Expand Down Expand Up @@ -154,3 +156,34 @@ <h4 class="mt-3">Pending NDC for all Participants</h4>
</ul>

<div class="mt-6" [ngbNavOutlet]="nav"></div>

<!-- Pending Approvals Modal -->
<ng-template #pendingApprovalsModal let-modal>
<div class="modal-body">
<div *ngFor="let result of approvalResult" class="row mb-2">
<div class="col-1">
<i
class="bi"
[ngClass]="{
'bi-check-circle': result.status === 'success',
'bi-exclamation-circle': result.status === 'error'
}"
[style.color]="result.status === 'success' ? 'green' : 'red'"
>
</i>
</div>
<div class="col-10">
{{ result.message }}
</div>
</div>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-success"
(click)="closePendingApprovalsModal()"
>
Ok
</button>
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from "@angular/core";
import { Component, OnInit, ViewChild } from "@angular/core";
import { ParticipantsService } from "../_services_and_types/participants.service";
import { MessageService } from "../_services_and_types/message.service";
import { BehaviorSubject } from "rxjs";
Expand Down Expand Up @@ -29,10 +29,17 @@ export class PendingApprovalsComponent implements OnInit {
fundAdjustmentCount: number = 0;
ndcRequestCount: number = 0;

approvalResult: BulkApprovalRequestResults[] = [];

@ViewChild("pendingApprovalsModal") // Get a reference to the depositModal
pendingApprovalsModal!: NgbModal;
pendingApprovalsModalRef?: NgbModalRef;

constructor(
private _participantsSvc: ParticipantsService,
private _messageService: MessageService
) { }
private _messageService: MessageService,
private _modalService: NgbModal
) {}

async ngOnInit(): Promise<void> {
console.log("PendingApprovalsComponent ngOnInit");
Expand Down Expand Up @@ -70,6 +77,13 @@ export class PendingApprovalsComponent implements OnInit {
const isChecked = e.target.checked;
if (isChecked) {
this.selectedFundAdjustment.push(fundAdjustment);

// Check if all Fund Adjustment requests are selected
if (
this.fundAdjustments.value.length === this.selectedFundAdjustment.length
) {
this.isFundAdjustmentSelectAll = true;
}
} else {
// find by id from fund adjustment and remove item from selectedFundAdjustment
const index = this.selectedFundAdjustment.findIndex(
Expand All @@ -78,6 +92,8 @@ export class PendingApprovalsComponent implements OnInit {
if (index !== -1) {
this.selectedFundAdjustment.splice(index, 1);
}

this.isFundAdjustmentSelectAll = false;
}
}

Expand All @@ -86,8 +102,14 @@ export class PendingApprovalsComponent implements OnInit {
ndcRequest: IParticipantPendingApproval["ndcChangeRequests"][number]
) {
const isChecked = e.target.checked;

if (isChecked) {
this.selectedNDCRequest.push(ndcRequest);

// Check if all NDC requests are selected
if (this.ndcRequests.value.length === this.selectedNDCRequest.length) {
this.isNDCSelectAll = true;
}
} else {
// find by id from fund adjustment and remove item from selectedFundAdjustment
const index = this.selectedNDCRequest.findIndex(
Expand All @@ -96,6 +118,8 @@ export class PendingApprovalsComponent implements OnInit {
if (index !== -1) {
this.selectedNDCRequest.splice(index, 1);
}

this.isNDCSelectAll = false;
}
}

Expand Down Expand Up @@ -138,13 +162,13 @@ export class PendingApprovalsComponent implements OnInit {
}

approveFundAdjustmentPendingApprovals() {
let fundAdjustments: IParticipantPendingApproval["fundsMovementRequest"] =
let fundAdjustments: IParticipantPendingApproval["fundsMovementRequest"] =
this.selectedFundAdjustment;

if (this.isFundAdjustmentSelectAll) {
fundAdjustments = this.fundAdjustments.value;
}

this._participantsSvc.submitPendingApprovals({
fundsMovementRequest: fundAdjustments,
ndcChangeRequests: [],
Expand All @@ -169,13 +193,7 @@ export class PendingApprovalsComponent implements OnInit {
if (error && error instanceof UnauthorizedError) {
this._messageService.addError(error.message);
}
},
() => {
// reset all selected options
this.selectedFundAdjustment = [];
this.isFundAdjustmentSelectAll = false;
}
);
);
}

rejectFundAdjustmentPendingApprovals() {
Expand Down Expand Up @@ -211,13 +229,7 @@ export class PendingApprovalsComponent implements OnInit {
if (error && error instanceof UnauthorizedError) {
this._messageService.addError(error.message);
}
},
() => {
// reset all selected options
this.selectedFundAdjustment = [];
this.isFundAdjustmentSelectAll = false;
}
);
);
}

approveNDCRequestPendingApprovals() {
Expand All @@ -226,7 +238,7 @@ export class PendingApprovalsComponent implements OnInit {
if (this.isFundAdjustmentSelectAll) {
ndcRequests = this.ndcRequests.value;
}

this._participantsSvc
.submitPendingApprovals({
fundsMovementRequest: [],
Expand All @@ -245,7 +257,7 @@ export class PendingApprovalsComponent implements OnInit {
this._messageService.addSuccess(result.message, 10000);
}
});

await this.getPendingApprovalsSummary();
await this.getPendingApprovals();
},
Expand All @@ -268,7 +280,7 @@ export class PendingApprovalsComponent implements OnInit {
if (this.isFundAdjustmentSelectAll) {
ndcRequests = this.ndcRequests.value;
}

this._participantsSvc
.submitPendingApprovals({
fundsMovementRequest: [],
Expand Down Expand Up @@ -340,9 +352,14 @@ export class PendingApprovalsComponent implements OnInit {
if (error && error instanceof UnauthorizedError) {
this._messageService.addError(error.message);
}
reject()
reject();
}
);
});
}

closePendingApprovalsModal() {
this.pendingApprovalsModalRef?.close();
this.approvalResult = [];
}
}