Enhancement/inverstor search data (#1838)
* Investor Search data * Investor module --------- Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
861cf7a000
commit
ed47d769e3
@@ -0,0 +1,70 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ExternalAssetOwnerService {
|
||||
|
||||
basePath = '/external-asset-owners';
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* @param {string} loanId Loan Id
|
||||
* @param {string} command Command
|
||||
* @param {any} data Data
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
executeExternalAssetOwnerLoanCommand(loanId: string, data: any, command: string): Observable<any> {
|
||||
const httpParams = new HttpParams().set('command', command);
|
||||
return this.http.post(`${this.basePath}/transfers/loans/${loanId}`, data, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} transferId Transfer Id
|
||||
* @param {string} command Command
|
||||
* @param {any} data Data
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
executeExternalAssetOwnerTransferCommand(transferId: string, data: any, command: string): Observable<any> {
|
||||
const httpParams = new HttpParams().set('command', command);
|
||||
return this.http.post(`${this.basePath}/transfers/${transferId}`, data, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} loanId Loan Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
retrieveExternalAssetOwnerTransfers(loanId: string): Observable<any> {
|
||||
const httpParams = new HttpParams().set('loanId', loanId);
|
||||
return this.http.get(`${this.basePath}/transfers`, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} loanId Loan Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
retrieveExternalAssetOwnerActiveTransfer(loanId: string): Observable<any> {
|
||||
const httpParams = new HttpParams().set('loanId', loanId);
|
||||
return this.http.get(`${this.basePath}/transfers/active-transfer`, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} transferId Transfer Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
retrieveExternalAssetOwnerTransferJournalEntries(transferId: string): Observable<any> {
|
||||
return this.http.get(`${this.basePath}/transfers/${transferId}/journal-entries`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} request Transfer Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
searchExternalAssetOwnerTransfer(request: any): Observable<any> {
|
||||
return this.http.post(`${this.basePath}/search`, request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ExternalAssetOwner {
|
||||
defaultDate = '9999-12-31';
|
||||
|
||||
validateStatus(item: any, status: string): boolean {
|
||||
if (item != null) {
|
||||
return (item.status === status);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
itemCurrentStatus(item: any): string {
|
||||
if (this.isBuyBackPending(item)) {
|
||||
return item.status + ' PENDING';
|
||||
}
|
||||
return item.status;
|
||||
}
|
||||
|
||||
itemStatus(status: string): string {
|
||||
return 'status-' + status.toLowerCase();
|
||||
}
|
||||
|
||||
isPending(item: any): boolean {
|
||||
return (item.status === 'PENDING');
|
||||
}
|
||||
|
||||
isPendingOrCanceled(item: any): boolean {
|
||||
return ((item.status === 'PENDING') || (item.status === 'CANCELLED') || this.isBuyBackPending(item));
|
||||
}
|
||||
|
||||
isBuyBackPending(item: any): boolean {
|
||||
return (item.status === 'BUYBACK' && item.effectiveTo === this.defaultDate);
|
||||
}
|
||||
|
||||
canBeCancelled(item: any): boolean {
|
||||
return this.validateStatus(item, 'PENDING');
|
||||
}
|
||||
|
||||
canBeSold(item: any): boolean {
|
||||
if (item == null) {
|
||||
return true;
|
||||
}
|
||||
return ['', 'CANCELLED'].includes(item.status)
|
||||
|| (item.status === 'BUYBACK' && item.effectiveTo !== this.defaultDate);
|
||||
}
|
||||
|
||||
canBeBuyed(item: any): boolean {
|
||||
return this.validateStatus(item, 'ACTIVE');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user