Skip to content

Commit

Permalink
Asset Externalization Owner management for Loans (#1771)
Browse files Browse the repository at this point in the history
Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
  • Loading branch information
josehernandezfintecheandomx and Jose Alberto Hernandez committed Jun 21, 2023
1 parent 1b60a8f commit bddf46c
Show file tree
Hide file tree
Showing 36 changed files with 702 additions and 124 deletions.
23 changes: 16 additions & 7 deletions src/app/accounting/accounting-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { AccountingComponent } from './accounting.component';
import { FrequentPostingsComponent } from './frequent-postings/frequent-postings.component';
import { CreateJournalEntryComponent } from './create-journal-entry/create-journal-entry.component';
import { SearchJournalEntryComponent } from './search-journal-entry/search-journal-entry.component';
import { ViewTransactionComponent } from './view-transaction/view-transaction.component';
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component';
Expand Down Expand Up @@ -45,7 +44,6 @@ import { AccountingRulesAssociationsResolver } from './common-resolvers/accounti
import { CurrenciesResolver } from './common-resolvers/currencies.resolver';
import { PaymentTypesResolver } from './common-resolvers/payment-types.resolver';
import { GlAccountsResolver } from './common-resolvers/gl-accounts.resolver';
import { TransactionResolver } from './view-transaction/transaction.resolver';
import { FinancialActivityMappingsResolver } from './financial-activity-mappings/financial-activity-mappings.resolver';
import { FinancialActivityMappingsTemplateResolver } from './financial-activity-mappings/create-financial-activity-mapping/financial-activity-mappings-template.resolver';
import { FinancialActivityMappingResolver } from './financial-activity-mappings/view-financial-activity-mapping/financial-activity-mapping.resolver';
Expand All @@ -64,6 +62,9 @@ import { ProvisioningEntryEntriesResolver } from './provisioning-entries/view-pr
import { LoanProductsResolver } from './common-resolvers/loan-products.resolver';
import { ProvisioningCategoriesResolver } from './common-resolvers/provisioning-categories.resolver';
import { ProvisioningJournalEntriesResolver } from './provisioning-entries/view-provisioning-journal-entries/provisioning-journal-entries.resolver';
import { ViewJournalEntryTransactionComponent } from 'app/shared/accounting/view-journal-entry-transaction/view-journal-entry-transaction.component';
import { JournalEntryTransactionResolver } from './common-resolvers/journal-entry-transaction.resolver';
import { ExternalAssetOwnerJournalEntryResolver } from 'app/loans/common-resolvers/external-asset-owner-journal-entry.resolver';

/** Accounting Routes */
const routes: Routes = [
Expand Down Expand Up @@ -116,10 +117,10 @@ const routes: Routes = [
children: [
{
path: 'view/:id',
component: ViewTransactionComponent,
component: ViewJournalEntryTransactionComponent,
data: { title: extract('View Transaction'), routeParamBreadcrumb: 'id' },
resolve: {
transaction: TransactionResolver
transaction: JournalEntryTransactionResolver
}
}
]
Expand Down Expand Up @@ -363,10 +364,18 @@ const routes: Routes = [
children: [
{
path: 'view/:id',
component: ViewTransactionComponent,
component: ViewJournalEntryTransactionComponent,
data: { title: extract('View Transaction'), routeParamBreadcrumb: 'id' },
resolve: {
transaction: TransactionResolver
transaction: JournalEntryTransactionResolver
}
},
{
path: 'view-transfer/:transferId',
component: ViewJournalEntryTransactionComponent,
data: { title: extract('View Transfer'), routeParamBreadcrumb: 'transferId' },
resolve: {
transferJournalEntryData: ExternalAssetOwnerJournalEntryResolver
}
}
]
Expand All @@ -388,7 +397,7 @@ const routes: Routes = [
CurrenciesResolver,
PaymentTypesResolver,
GlAccountsResolver,
TransactionResolver,
JournalEntryTransactionResolver,
FinancialActivityMappingsResolver,
FinancialActivityMappingsTemplateResolver,
FinancialActivityMappingResolver,
Expand Down
4 changes: 0 additions & 4 deletions src/app/accounting/accounting.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { AccountingComponent } from './accounting.component';
import { FrequentPostingsComponent } from './frequent-postings/frequent-postings.component';
import { CreateJournalEntryComponent } from './create-journal-entry/create-journal-entry.component';
import { SearchJournalEntryComponent } from './search-journal-entry/search-journal-entry.component';
import { ViewTransactionComponent } from './view-transaction/view-transaction.component';
import { RevertTransactionComponent } from './revert-transaction/revert-transaction.component';
import { ViewJournalEntryComponent } from './view-journal-entry/view-journal-entry.component';
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component';
Expand Down Expand Up @@ -55,9 +53,7 @@ import { PipesModule } from 'app/pipes/pipes.module';
FrequentPostingsComponent,
CreateJournalEntryComponent,
SearchJournalEntryComponent,
ViewTransactionComponent,
RevertTransactionComponent,
ViewJournalEntryComponent,
FinancialActivityMappingsComponent,
CreateFinancialActivityMappingComponent,
ViewFinancialActivityMappingComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AccountingService } from '../accounting.service';
* Transaction data resolver.
*/
@Injectable()
export class TransactionResolver implements Resolve<Object> {
export class JournalEntryTransactionResolver implements Resolve<Object> {

/**
* @param {AccountingService} accountingService Accounting service.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ExternalAssetOwnerService } from '../external-asset-owner.service';

@Injectable({
providedIn: 'root'
})
export class ExternalAssetOwnerActiveTransferResolver implements Resolve<boolean> {

/**
* @param {ExternalAssetOwnerService} externalAssetOwnerService External Asset Owner service.
*/
constructor(private externalAssetOwnerService: ExternalAssetOwnerService) { }

/**
* Returns the Loans with Association data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId');
return this.externalAssetOwnerService.retrieveExternalAssetOwnerActiveTransfer(loanId);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { ExternalAssetOwnerService } from '../external-asset-owner.service';

@Injectable({
providedIn: 'root'
})
export class ExternalAssetOwnerJournalEntryResolver implements Resolve<boolean> {

/**
* @param {ExternalAssetOwnerService} externalAssetOwnerService External Asset Owner service.
*/
constructor(private externalAssetOwnerService: ExternalAssetOwnerService) { }

/**
* Returns the Loans with Association data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const transferId = route.paramMap.get('transferId') || route.parent.paramMap.get('transferId');
return this.externalAssetOwnerService.retrieveExternalAssetOwnerTransferJournalEntries(transferId);
}

}
25 changes: 25 additions & 0 deletions src/app/loans/common-resolvers/external-asset-owner.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ExternalAssetOwnerService } from '../external-asset-owner.service';

@Injectable({
providedIn: 'root'
})
export class ExternalAssetOwnerResolver implements Resolve<boolean> {

/**
* @param {ExternalAssetOwnerService} externalAssetOwnerService External Asset Owner service.
*/
constructor(private externalAssetOwnerService: ExternalAssetOwnerService) { }

/**
* Returns the Loans with Association data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId');
return this.externalAssetOwnerService.retrieveExternalAssetOwnerTransfers(loanId);
}

}
49 changes: 49 additions & 0 deletions src/app/loans/external-asset-owner.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
providedIn: 'root'
})
export class ExternalAssetOwnerService {

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(`/external-asset-owners/transfers/loans/${loanId}`, 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(`/external-asset-owners/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(`/external-asset-owners/transfers/active-transfer`, { params: httpParams });
}

/**
* @param {string} transferId Transfer Id
* @returns {Observable<any>}
*/
retrieveExternalAssetOwnerTransferJournalEntries(transferId: string): Observable<any> {
return this.http.get(`/external-asset-owners/transfers/${transferId}/journal-entries`);
}

}
16 changes: 15 additions & 1 deletion src/app/loans/loans-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ import { LoanReschedulesResolver } from './common-resolvers/loan-reschedules.res
import { RescheduleLoanTabComponent } from './loans-view/reschedule-loan-tab/reschedule-loan-tab.component';
import { AdjustLoanChargeComponent } from './loans-view/loan-account-actions/adjust-loan-charge/adjust-loan-charge.component';
import { LoanArrearDelinquencyResolver } from './common-resolvers/loan-arrear-delinquency.resolver';
import { ExternalAssetOwnerTabComponent } from './loans-view/external-asset-owner-tab/external-asset-owner-tab.component';
import { ExternalAssetOwnerResolver } from './common-resolvers/external-asset-owner.resolver';
import { ExternalAssetOwnerActiveTransferResolver } from './common-resolvers/external-asset-owner-active-transfer.resolver';
import { ExternalAssetOwnerJournalEntryResolver } from './common-resolvers/external-asset-owner-journal-entry.resolver';

/** Loans Route. */
const routes: Routes = [
Expand Down Expand Up @@ -198,6 +202,15 @@ const routes: Routes = [
component: StandingInstructionsTabComponent,
data: { title: extract('Standing Instructions'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false }
},
{
path: 'external-asset-owner',
component: ExternalAssetOwnerTabComponent,
data: { title: extract('External Asset Owner'), breadcrumb: 'External Asset Owner', routeParamBreadcrumb: false },
resolve: {
activeTransferData: ExternalAssetOwnerActiveTransferResolver,
loanTransfersData: ExternalAssetOwnerResolver
}
},
{
path: 'datatables',
children: [{
Expand Down Expand Up @@ -349,7 +362,8 @@ const routes: Routes = [
GroupAccountsResolver,
GLIMViewResolver,
GSIMAccountsResolver,
GLIMLoanTemplateResolver
GLIMLoanTemplateResolver,
ExternalAssetOwnerResolver
]
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<div class="tab-container mat-typography">
<div fxLayout="row" fxLayoutAlign="start center">

<h3 fxFlex="90%">External Asset Owner</h3>

<div fxFlex="10%" *ngIf="canBeSaled()" >
<button mat-raised-button class="f-right" color="primary" (click)="saleLoan()" *mifosxHasPermission="'SALE_LOAN'">
<fa-icon icon="dollar-sign" class="m-r-10"></fa-icon>Sale Loan
</button>
</div>

<div fxFlex="10%" *ngIf="canBeCancelled()" >
<button mat-raised-button class="f-right" color="warn" (click)="cancelSaleLoan()" *mifosxHasPermission="'SALE_LOAN'">
<fa-icon icon="trash" class="m-r-10"></fa-icon>Cancel Sale Loan
</button>
</div>

<div fxFlex="10%" *ngIf="canBeBuyed()" >
<button mat-raised-button class="f-right" color="primary" (click)="buyBackLoan()" *mifosxHasPermission="'SALE_LOAN'">
<fa-icon icon="dollar-sign" class="m-r-10"></fa-icon>Buy Back Loan
</button>
</div>
</div>

<table mat-table mat-sort [dataSource]="loanTransfersData" *ngIf="loanTransfersData.length>0">

<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let item">
<div [ngClass]="itemStatus(item.status)">
<fa-icon icon="stop"></fa-icon>
<span class="m-l-10 status">
{{ item.status | translate }}
</span>
</div>
</td>
</ng-container>

<ng-container matColumnDef="effectiveFrom">
<th mat-header-cell *matHeaderCellDef> Effective From </th>
<td mat-cell *matCellDef="let item"> {{ item.effectiveFrom | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="ownerExternalId">
<th mat-header-cell *matHeaderCellDef> Owner External Id </th>
<td mat-cell *matCellDef="let item">
<mifosx-external-identifier externalId="{{item.owner.externalId}}"></mifosx-external-identifier>
</td>
</ng-container>

<ng-container matColumnDef="transferExternalId">
<th mat-header-cell *matHeaderCellDef> Transfer External Id </th>
<td mat-cell *matCellDef="let item">
<mifosx-external-identifier externalId="{{item.transferExternalId}}"></mifosx-external-identifier>
</td>
</ng-container>

<ng-container matColumnDef="settlementDate">
<th mat-header-cell *matHeaderCellDef> Settlement Date </th>
<td mat-cell *matCellDef="let item"> {{ item.settlementDate | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="purchasePriceRatio">
<th mat-header-cell *matHeaderCellDef> Purchase Price Ratio </th>
<td mat-cell *matCellDef="let item"> {{ item.purchasePriceRatio | number }}</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell class="center" *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let item" class="center td-min-space">
<button class="account-action-button" *ngIf="!isPending(item)" mat-raised-button color="primary" matTooltip="View Journal Entries"
matTooltipPosition="left" (click)="routeJournalEntry($event)" [routerLink]="['/', 'journal-entry', 'view-transfer', item.transferId]">
<i class="fa fa-arrow-circle-right"></i>
</button>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="loanTransferColumns"></tr>
<tr mat-row *matRowDef="let row; columns: loanTransferColumns;"></tr>
</table>
</div>
Loading

0 comments on commit bddf46c

Please sign in to comment.