Asset Externalization Owner management for Loans (#1771)

Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
José Alberto Hernández
2023-06-21 12:17:47 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 1b60a8f43c
commit bddf46cccd
36 changed files with 704 additions and 126 deletions
@@ -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';
@@ -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';
@@ -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 = [
@@ -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
}
}
]
@@ -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
}
}
]
@@ -388,7 +397,7 @@ const routes: Routes = [
CurrenciesResolver,
PaymentTypesResolver,
GlAccountsResolver,
TransactionResolver,
JournalEntryTransactionResolver,
FinancialActivityMappingsResolver,
FinancialActivityMappingsTemplateResolver,
FinancialActivityMappingResolver,
-4
View File
@@ -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';
@@ -55,9 +53,7 @@ import { PipesModule } from 'app/pipes/pipes.module';
FrequentPostingsComponent,
CreateJournalEntryComponent,
SearchJournalEntryComponent,
ViewTransactionComponent,
RevertTransactionComponent,
ViewJournalEntryComponent,
FinancialActivityMappingsComponent,
CreateFinancialActivityMappingComponent,
ViewFinancialActivityMappingComponent,
@@ -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.
@@ -1,117 +0,0 @@
<h1 mat-dialog-title>View Journal Entry</h1>
<div mat-dialog-content>
<table>
<tr>
<th>Office</th>
<td>{{ data.journalEntry.officeName }}</td>
</tr>
<tr>
<th>Entry ID</th>
<td>{{ data.journalEntry.id }}</td>
</tr>
<tr>
<th>Transaction ID</th>
<td>{{ data.journalEntry.transactionId }}</td>
</tr>
<tr>
<th>Transaction Date</th>
<td>{{ data.journalEntry.transactionDate | dateFormat }}</td>
</tr>
<tr>
<th>Type</th>
<td>{{ data.journalEntry.glAccountType.value }}</td>
</tr>
<tr>
<th>Account Code</th>
<td>{{ data.journalEntry.glAccountId }}</td>
</tr>
<tr>
<th>Account Name</th>
<td>{{ data.journalEntry.glAccountName }}</td>
</tr>
<tr>
<th>
<span *ngIf="data.journalEntry.entryType.value === 'CREDIT'">Credit</span>
<span *ngIf="data.journalEntry.entryType.value === 'DEBIT'">Debit</span>
</th>
<td>
{{ data.journalEntry.currency.displaySymbol }} {{ data.journalEntry.amount | formatNumber }}
</td>
</tr>
<tr>
<th>Currency</th>
<td>({{ data.journalEntry.currency.code }}) {{ data.journalEntry.currency.name }}</td>
</tr>
<tr *ngIf="data.journalEntry.referenceNumber">
<th>Reference Number</th>
<td>{{ data.journalEntry.referenceNumber }}</td>
</tr>
<tr *ngIf="data.journalEntry.comments">
<th>Comments</th>
<td>{{ data.journalEntry.comments }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails">
<th colspan="2" class="header">Payment Details</th>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.paymentType">
<th>Payment Type</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.paymentType.name }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.accountNumber">
<th>Account Number</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.accountNumber }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.checkNumber">
<th>Cheque Number</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.checkNumber }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.routingCode">
<th>Routing Code</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.routingCode }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.receiptNumber">
<th>Receipt Number</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.receiptNumber }}</td>
</tr>
<tr *ngIf="data.journalEntry.transactionDetails.paymentDetails?.bankNumber">
<th>Bank Number</th>
<td>{{ data.journalEntry.transactionDetails.paymentDetails.bankNumber }}</td>
</tr>
<tr>
<th>Created by</th>
<td>{{ data.journalEntry.createdByUserName }}</td>
</tr>
<tr>
<th>Submitted on</th>
<td>{{ data.journalEntry.submittedOnDate | datetimeFormat }}</td>
</tr>
</table>
</div>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>Close</button>
</mat-dialog-actions>
@@ -1,16 +0,0 @@
table {
th {
text-align: left;
font-weight: 500;
padding: 0 0.4rem 0 0;
&.header {
text-align: center;
padding: 0.4rem 0.4rem 0 0;
}
}
td {
padding: 0 0.4rem 0 0;
}
}
@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewJournalEntryComponent } from './view-journal-entry.component';
describe('ViewJournalEntryComponent', () => {
let component: ViewJournalEntryComponent;
let fixture: ComponentFixture<ViewJournalEntryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewJournalEntryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewJournalEntryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
/** Angular Imports */
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
/**
* View journal entry dialog component.
*/
@Component({
selector: 'mifosx-view-journal-entry',
templateUrl: './view-journal-entry.component.html',
styleUrls: ['./view-journal-entry.component.scss']
})
export class ViewJournalEntryComponent implements OnInit {
/**
* @param {MatDialogRef} dialogRef Component reference to dialog.
* @param {any} data Provides journal entry.
*/
constructor(public dialogRef: MatDialogRef<ViewJournalEntryComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit() {
}
}
@@ -1,101 +0,0 @@
<div fxLayout="row" fxLayoutAlign="end" class="container m-b-20" *ngIf="dataSource?.data[0].manualEntry">
<button mat-raised-button color="primary" (click)="revertTransaction()" *mifosxHasPermission="'REVERSE_JOURNALENTRY'" [disabled]="dataSource?.data[0].reversed">
<span *ngIf="!dataSource.data[0].reversed">
<fa-icon icon="undo" class="m-r-10"></fa-icon>Revert Transaction
</span>
<span *ngIf="dataSource.data[0].reversed">Transaction Reverted</span>
</button>
</div>
<div class="container m-b-20">
<mat-card class="mat-elevation-z8" *ngIf="dataSource">
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Office
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].officeName }}
</div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Transaction Date
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].transactionDate | dateFormat }}
</div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Created By
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].createdByUserName }}
</div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Submitted on
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].submittedOnDate | datetimeFormat }}
</div>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="mat-elevation-z8 container" fxLayoutAlign="center" fxLayout="row wrap">
<table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="id">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Entry ID </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.id }} </td>
</ng-container>
<ng-container matColumnDef="glAccountType">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Type </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountType.value }} </td>
</ng-container>
<ng-container matColumnDef="glAccountCode">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Account Code </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountCode }} </td>
</ng-container>
<ng-container matColumnDef="glAccountName">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Account Name </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.glAccountName }} </td>
</ng-container>
<ng-container matColumnDef="debit">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Debit </th>
<td mat-cell *matCellDef="let transaction"><span *ngIf="transaction.entryType.value === 'DEBIT'"> {{ (transaction.currency.displaySymbol || transaction.currency.code) }} {{ transaction.amount | formatNumber }} </span></td>
</ng-container>
<ng-container matColumnDef="credit">
<th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Credit </th>
<td mat-cell *matCellDef="let transaction"><span *ngIf="transaction.entryType.value === 'CREDIT'"> {{ (transaction.currency.displaySymbol || transaction.currency.code) }} {{ transaction.amount | formatNumber }} </span></td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="viewJournalEntry(row)" class="select-row"></tr>
</table>
<div fxLayoutAlign="center" fxLayoutGap="2%" fxLayout.lt-md="column" class="action-bar">
<button type="button" color="primary" mat-raised-button (click)="goBack()">Back</button>
</div>
</div>
@@ -1,28 +0,0 @@
.content {
div {
line-height: 3rem;
&.header {
font-weight: 500;
}
}
}
.container {
max-width: 75rem;
}
table {
width: 98%;
.select-row:hover {
cursor: pointer;
}
}
.action-bar {
width: 98%;
align-items: center;
padding-top: 15px;
padding-bottom: 15px;
}
@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewTransactionComponent } from './view-transaction.component';
describe('ViewTransactionComponent', () => {
let component: ViewTransactionComponent;
let fixture: ComponentFixture<ViewTransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewTransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewTransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,117 +0,0 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
/** Custom Services */
import { AccountingService } from '../accounting.service';
/** Custom Components */
import { RevertTransactionComponent } from '../revert-transaction/revert-transaction.component';
import { ViewJournalEntryComponent } from '../view-journal-entry/view-journal-entry.component';
import { Location } from '@angular/common';
/**
* View transaction component.
*/
@Component({
selector: 'mifosx-view-transaction',
templateUrl: './view-transaction.component.html',
styleUrls: ['./view-transaction.component.scss']
})
export class ViewTransactionComponent implements OnInit {
// TODO: Update once language and date settings are setup
/** Transaction data. */
transaction: any;
/** Transaction ID. */
transactionId: string;
/** Columns to be displayed in transaction table. */
displayedColumns: string[] = ['id', 'glAccountType', 'glAccountCode', 'glAccountName', 'debit', 'credit'];
/** Data source for transaction table. */
dataSource: MatTableDataSource<any>;
/** Paginator for transaction table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** Sorter for transaction table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/**
* @param {AccountingService} accountingService Accounting Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private accountingService: AccountingService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
private location: Location) { }
/**
* Retrieves the transaction data from `resolve` and sets the transaction table.
*/
ngOnInit() {
this.route.data.subscribe((data: { transaction: any }) => {
this.transaction = data.transaction;
this.transactionId = data.transaction.pageItems[0].transactionId;
this.setTransaction();
});
}
/**
* Initializes the data source for transaction table with journal entries, paginator and sorter.
*/
setTransaction() {
this.dataSource = new MatTableDataSource(this.transaction.pageItems);
this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (transaction: any, property: any) => {
switch (property) {
case 'glAccountType': return transaction.glAccountType.value;
case 'debit': return transaction.amount;
case 'credit': return transaction.amount;
default: return transaction[property];
}
};
this.dataSource.sort = this.sort;
}
/**
* View details of selected journal entry.
* @param {any} journalEntry Selected journal entry.
*/
viewJournalEntry(journalEntry: any) {
this.dialog.open(ViewJournalEntryComponent, {
data: { journalEntry: journalEntry }
});
}
/**
* Reverts the given transaction and redirects to reverted transaction.
* @param {transactionId} transactionId Transaction ID of transaction to be reverted.
*/
revertTransaction(transactionId?: string) {
const revertTransactionDialogRef = this.dialog.open(RevertTransactionComponent, {
data: { reverted: this.dataSource.data[0].reversed, transactionId: transactionId }
});
revertTransactionDialogRef.afterClosed().subscribe((response: any) => {
if (response.revert) {
this.accountingService.revertTransaction(this.transactionId, response.comments).subscribe((reversedTransaction: any) => {
this.dataSource.data[0].reversed = true;
this.revertTransaction(reversedTransaction.transactionId);
});
} else if (response.redirect) {
this.router.navigate(['../', transactionId], { relativeTo: this.route });
}
});
}
goBack(): void {
this.location.back();
}
}