Documents and Notes for Clients, Loans and Clients (#1632)
Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
28d5d7595f
commit
cafe8fa73d
@@ -1,47 +1,7 @@
|
|||||||
<div class="tab-container mat-typography">
|
<mifosx-entity-documents-tab [entityType]="entityType" [entityId]="entityId"
|
||||||
|
[entityDocuments]="entityDocuments"
|
||||||
<!-- Documents Table -->
|
[callbackUpload]="uploadDocument"
|
||||||
|
[callbackDownload]="downloadDocument"
|
||||||
<h3>Documents</h3>
|
[callbackDelete]="deleteDocument"
|
||||||
|
>
|
||||||
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()"
|
</mifosx-entity-documents-tab>
|
||||||
*mifosxHasPermission="'CREATE_DOCUMENT'">
|
|
||||||
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<table mat-table #documentsTable [dataSource]="clientDocuments" matSort>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Name </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{document.name}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="description">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Description </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{document.description}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="fileName">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> File Name </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{document.fileName}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
|
||||||
<td mat-cell *matCellDef="let document; let i = index">
|
|
||||||
<button class="document-action-button" mat-raised-button color="primary"
|
|
||||||
(click)="download(document.parentEntityId,document.id)">
|
|
||||||
<fa-icon icon="cloud-download-alt"></fa-icon>
|
|
||||||
</button>
|
|
||||||
<button class="document-action-button" mat-raised-button color="warn"
|
|
||||||
(click)="deleteDocument(document.parentEntityId,document.id,i)">
|
|
||||||
<fa-icon icon="times"></fa-icon>
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="documentsColumns"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: documentsColumns;"></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,84 +1,45 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { MatTable } from '@angular/material/table';
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { ClientsService } from '../../clients.service';
|
import { ClientsService } from '../../clients.service';
|
||||||
|
|
||||||
/** Custom Components */
|
|
||||||
import { UploadDocumentDialogComponent } from '../custom-dialogs/upload-document-dialog/upload-document-dialog.component';
|
|
||||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'mifosx-documents-tab',
|
selector: 'mifosx-documents-tab',
|
||||||
templateUrl: './documents-tab.component.html',
|
templateUrl: './documents-tab.component.html',
|
||||||
styleUrls: ['./documents-tab.component.scss']
|
styleUrls: ['./documents-tab.component.scss']
|
||||||
})
|
})
|
||||||
export class DocumentsTabComponent implements OnInit {
|
export class DocumentsTabComponent implements OnInit {
|
||||||
@ViewChild('documentsTable', { static: true }) documentsTable: MatTable<Element>;
|
entityDocuments: any;
|
||||||
documentsColumns: string[] = ['name', 'description', 'fileName', 'actions'];
|
entityId: string;
|
||||||
clientDocuments: any;
|
entityType: string = 'clients';
|
||||||
clientId: string;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private clientService: ClientsService,
|
private clientsService: ClientsService,
|
||||||
public dialog: MatDialog) {
|
public dialog: MatDialog) {
|
||||||
this.route.data.subscribe((data: { clientDocuments: any }) => {
|
this.route.data.subscribe((data: { clientDocuments: any }) => {
|
||||||
this.clientDocuments = data.clientDocuments;
|
this.entityDocuments = data.clientDocuments;
|
||||||
});
|
});
|
||||||
this.clientId = this.route.parent.snapshot.paramMap.get('clientId');
|
this.entityId = this.route.parent.snapshot.paramMap.get('clientId');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
download(parentEntityId: string, documentId: string) {
|
downloadDocument(documentId: string) {
|
||||||
this.clientService.downloadClientDocument(parentEntityId, documentId).subscribe(res => {
|
this.clientsService.downloadClientDocument(this.entityId, documentId).subscribe(res => {
|
||||||
const url = window.URL.createObjectURL(res);
|
const url = window.URL.createObjectURL(res);
|
||||||
window.open(url);
|
window.open(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteDocument(parentEntityId: string, documentId: string, index: number) {
|
deleteDocument(documentId: string) {
|
||||||
const deleteDocumentDialogRef = this.dialog.open(DeleteDialogComponent, {
|
this.clientsService.deleteClientDocument(this.entityId, documentId).subscribe(res => {});
|
||||||
data: { deleteContext: `document id:${documentId}` }
|
|
||||||
});
|
|
||||||
deleteDocumentDialogRef.afterClosed().subscribe((response: any) => {
|
|
||||||
if (response.delete) {
|
|
||||||
this.clientService.deleteClientDocument(parentEntityId, documentId).subscribe(res => {
|
|
||||||
this.clientDocuments.splice(index, 1);
|
|
||||||
this.documentsTable.renderRows();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadDocument() {
|
uploadDocument(formData: FormData): any {
|
||||||
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
|
return this.clientsService.uploadClientDocument(this.entityId, formData);
|
||||||
data: { documentIdentifier: false, entityType: 'Client' }
|
|
||||||
});
|
|
||||||
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
|
||||||
if (dialogResponse) {
|
|
||||||
const formData: FormData = new FormData;
|
|
||||||
formData.append('name', dialogResponse.fileName);
|
|
||||||
formData.append('file', dialogResponse.file);
|
|
||||||
formData.append('description', dialogResponse.description);
|
|
||||||
this.clientService.uploadClientDocument(this.clientId, formData).subscribe((res: any) => {
|
|
||||||
this.clientDocuments.push({
|
|
||||||
id: res.resourceId,
|
|
||||||
parentEntityType: 'clients',
|
|
||||||
parentEntityId: this.clientId,
|
|
||||||
name: dialogResponse.fileName,
|
|
||||||
description: dialogResponse.description,
|
|
||||||
fileName: dialogResponse.file.name
|
|
||||||
});
|
|
||||||
this.documentsTable.renderRows();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,7 @@
|
|||||||
<div class="tab-container mat-typography">
|
<mifosx-entity-notes-tab [entityId]="entityId"
|
||||||
|
[entityNotes]="entityNotes"
|
||||||
<h3>Notes</h3>
|
[callbackAdd]="addNote"
|
||||||
|
[callbackEdit]="editNote"
|
||||||
<div>
|
[callbackDelete]="deleteNote"
|
||||||
|
>
|
||||||
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
</mifosx-entity-notes-tab>
|
||||||
(ngSubmit)="submit()">
|
|
||||||
|
|
||||||
<mat-form-field fxFlex="calc(90%-20px)">
|
|
||||||
<textarea formControlName="note" matInput placeholder="Write a note ...."></textarea>
|
|
||||||
</mat-form-field>
|
|
||||||
|
|
||||||
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid" *mifosxHasPermission="'CREATE_CLIENTNOTE'">
|
|
||||||
<fa-icon icon="plus"></fa-icon> Add
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<mat-list>
|
|
||||||
|
|
||||||
<mat-list-item *ngFor="let clientNote of clientNotes; let i=index;">
|
|
||||||
<fa-icon icon="sticky-note" matListIcon></fa-icon>
|
|
||||||
<h3 matLine>{{clientNote.note}} </h3>
|
|
||||||
<p matLine>
|
|
||||||
<span>Created by: {{clientNote.createdByUsername}}</span><br />
|
|
||||||
<span>Date: {{clientNote.createdOn | dateFormat}}</span>
|
|
||||||
</p>
|
|
||||||
<div fxLayout="row" fxLayoutAlign="flex-start">
|
|
||||||
<button mat-button color="primary" (click)="editNote(clientNote.id,clientNote.note,i)" *mifosxHasPermission="'CREATE_CLIENTNOTE'">
|
|
||||||
<fa-icon icon="edit"></fa-icon>
|
|
||||||
</button>
|
|
||||||
<button mat-button color="warn" (click)="deleteNote(clientNote.id,i)" *mifosxHasPermission="'DELETE_CLIENTNOTE'">
|
|
||||||
<fa-icon icon="trash"></fa-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</mat-list-item>
|
|
||||||
|
|
||||||
</mat-list>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
.tab-container {
|
|
||||||
padding: 1%;
|
|
||||||
margin: 1%;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|
||||||
|
|
||||||
/** Custom Components */
|
/** Custom Components */
|
||||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
|
||||||
import { EditNotesDialogComponent } from '../custom-dialogs/edit-notes-dialog/edit-notes-dialog.component';
|
|
||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { ClientsService } from '../../clients.service';
|
import { ClientsService } from '../../clients.service';
|
||||||
@@ -23,66 +19,39 @@ import { AuthenticationService } from 'app/core/authentication/authentication.se
|
|||||||
export class NotesTabComponent implements OnInit {
|
export class NotesTabComponent implements OnInit {
|
||||||
|
|
||||||
/** Client ID */
|
/** Client ID */
|
||||||
clientId: string;
|
entityId: string;
|
||||||
/** Username */
|
/** Username */
|
||||||
username: string;
|
username: string;
|
||||||
/** Client Notes */
|
/** Client Notes */
|
||||||
clientNotes: any;
|
entityNotes: any;
|
||||||
/** Note Form */
|
|
||||||
noteForm: FormGroup;
|
|
||||||
|
|
||||||
/** Notes Form Reference */
|
|
||||||
@ViewChild('formRef', { static: true }) formRef: any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ActivatedRoute} route Activated Route
|
* @param {ActivatedRoute} route Activated Route
|
||||||
* @param {FormBuilder} formBuilder Form Builder
|
|
||||||
* @param {ClientsService} clientsService Clients Service
|
* @param {ClientsService} clientsService Clients Service
|
||||||
* @param {AuthenticationService} authenticationService Authentication Service
|
* @param {AuthenticationService} authenticationService Authentication Service
|
||||||
* @param {MatDialog} dialog Mat Dialog
|
|
||||||
*/
|
*/
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
private clientsService: ClientsService,
|
private clientsService: ClientsService,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService) {
|
||||||
public dialog: MatDialog) {
|
|
||||||
const credentials = this.authenticationService.getCredentials();
|
const credentials = this.authenticationService.getCredentials();
|
||||||
this.username = credentials.username;
|
this.username = credentials.username;
|
||||||
this.clientId = this.route.parent.snapshot.params['clientId'];
|
this.entityId = this.route.parent.snapshot.params['clientId'];
|
||||||
this.route.data.subscribe((data: { clientNotes: any }) => {
|
this.route.data.subscribe((data: { clientNotes: any }) => {
|
||||||
this.clientNotes = data.clientNotes;
|
this.entityNotes = data.clientNotes;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() { }
|
||||||
this.createNoteForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the note form
|
|
||||||
*/
|
|
||||||
createNoteForm() {
|
|
||||||
this.noteForm = this.formBuilder.group({
|
|
||||||
'note': ['', Validators.required]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits a client note.
|
* Edits a client note.
|
||||||
* @param {string} noteId Note Id
|
* @param {string} noteId Note Id
|
||||||
* @param {string} noteContent Note Content
|
* @param {any} noteContent Note Content
|
||||||
* @param {number} index Index
|
* @param {number} index Index
|
||||||
*/
|
*/
|
||||||
editNote(noteId: string, noteContent: string, index: number) {
|
editNote(noteId: string, noteContent: any, index: number) {
|
||||||
const editNoteDialogRef = this.dialog.open(EditNotesDialogComponent, {
|
this.clientsService.editClientNote(this.entityId, noteId, noteContent).subscribe(() => {
|
||||||
data: { noteContent: noteContent }
|
this.entityNotes[index].note = noteContent.note;
|
||||||
});
|
|
||||||
editNoteDialogRef.afterClosed().subscribe((response: { editForm: any }) => {
|
|
||||||
if (response.editForm) {
|
|
||||||
this.clientsService.editClientNote(this.clientId, noteId, response.editForm.value).subscribe(() => {
|
|
||||||
this.clientNotes[index].note = response.editForm.value.note;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,31 +61,23 @@ export class NotesTabComponent implements OnInit {
|
|||||||
* @param {number} index Index
|
* @param {number} index Index
|
||||||
*/
|
*/
|
||||||
deleteNote(noteId: string, index: number) {
|
deleteNote(noteId: string, index: number) {
|
||||||
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
|
this.clientsService.deleteClientNote(this.entityId, noteId)
|
||||||
data: { deleteContext: `Note id:${noteId}` }
|
.subscribe(() => {
|
||||||
});
|
this.entityNotes.splice(index, 1);
|
||||||
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
|
});
|
||||||
if (response.delete) {
|
|
||||||
this.clientsService.deleteClientNote(this.clientId, noteId)
|
|
||||||
.subscribe(() => {
|
|
||||||
this.clientNotes.splice(index, 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a client note.
|
* Creates a client note.
|
||||||
*/
|
*/
|
||||||
submit() {
|
addNote(noteContent: any) {
|
||||||
this.clientsService.createClientNote(this.clientId, this.noteForm.value).subscribe((response: any) => {
|
this.clientsService.createClientNote(this.entityId, noteContent).subscribe((response: any) => {
|
||||||
this.clientNotes.push({
|
this.entityNotes.push({
|
||||||
id: response.resourceId,
|
id: response.resourceId,
|
||||||
createdByUsername: this.username,
|
createdByUsername: this.username,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
note: this.noteForm.value.note
|
note: noteContent.note
|
||||||
});
|
});
|
||||||
this.formRef.resetForm();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,19 +27,19 @@
|
|||||||
|
|
||||||
<!-- Name Column -->
|
<!-- Name Column -->
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header="displayName"> Name </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header="entityName"> Name </th>
|
||||||
<td mat-cell *matCellDef="let row"> {{row.entityName}} </td>
|
<td mat-cell *matCellDef="let row"> {{row.entityName}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Account no Column -->
|
<!-- Account no Column -->
|
||||||
<ng-container matColumnDef="clientNo">
|
<ng-container matColumnDef="clientNo">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header="accountNo"> Account No. </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header="entityAccountNo"> Account No. </th>
|
||||||
<td mat-cell *matCellDef="let row"> {{row.entityAccountNo}} </td>
|
<td mat-cell *matCellDef="let row"> {{row.entityAccountNo}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- External ID Column -->
|
<!-- External ID Column -->
|
||||||
<ng-container matColumnDef="externalId">
|
<ng-container matColumnDef="externalId">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header="externalId"> External Id </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header="entityExternalId"> External Id </th>
|
||||||
<td mat-cell *matCellDef="let row">
|
<td mat-cell *matCellDef="let row">
|
||||||
<mifosx-external-identifier externalId="{{row.entityExternalId}}"></mifosx-external-identifier>
|
<mifosx-external-identifier externalId="{{row.entityExternalId}}"></mifosx-external-identifier>
|
||||||
</td>
|
</td>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<!-- Status Column -->
|
<!-- Status Column -->
|
||||||
<ng-container matColumnDef="status">
|
<ng-container matColumnDef="status">
|
||||||
<th mat-header-cell *matHeaderCellDef> Status </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header="entityStatus.value"> Status </th>
|
||||||
<td mat-cell *matCellDef="let row">
|
<td mat-cell *matCellDef="let row">
|
||||||
<div [ngClass]="row.entityStatus.code | statusLookup">
|
<div [ngClass]="row.entityStatus.code | statusLookup">
|
||||||
<fa-icon icon="stop"></fa-icon>
|
<fa-icon icon="stop"></fa-icon>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<mat-paginator [pageSize]="50" [pageSizeOptions]="[10, 25, 50, 100]"
|
<mat-paginator *ngIf="moreClientsToFilter" [pageSize]="50" [pageSizeOptions]="[10, 25, 50, 100]"
|
||||||
showFirstLastButtons></mat-paginator>
|
showFirstLastButtons></mat-paginator>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { MatTableDataSource } from '@angular/material/table';
|
|||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { SearchService } from 'app/search/search.service';
|
import { SearchService } from 'app/search/search.service';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'mifosx-clients',
|
selector: 'mifosx-clients',
|
||||||
@@ -29,7 +30,9 @@ export class ClientsComponent implements OnInit {
|
|||||||
constructor(private searchService: SearchService) { }
|
constructor(private searchService: SearchService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getClients('');
|
if (environment.preloadClients) {
|
||||||
|
this.getClients('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -63,6 +63,14 @@
|
|||||||
|
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step *ngFor="let datatable of datatables">
|
||||||
|
|
||||||
|
<ng-template matStepLabel>{{datatable.registeredTableName}}</ng-template>
|
||||||
|
|
||||||
|
<mifosx-loans-account-datatable-step [datatableData]="datatable" #dtloan></mifosx-loans-account-datatable-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
<mat-step state="preview" *ngIf="loansAccountFormValid" completed>
|
<mat-step state="preview" *ngIf="loansAccountFormValid" completed>
|
||||||
|
|
||||||
<ng-template matStepLabel>PREVIEW</ng-template>
|
<ng-template matStepLabel>PREVIEW</ng-template>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
@@ -12,6 +12,7 @@ import { LoansAccountDetailsStepComponent } from '../loans-account-stepper/loans
|
|||||||
import { LoansAccountTermsStepComponent } from '../loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component';
|
import { LoansAccountTermsStepComponent } from '../loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component';
|
||||||
import { LoansAccountChargesStepComponent } from '../loans-account-stepper/loans-account-charges-step/loans-account-charges-step.component';
|
import { LoansAccountChargesStepComponent } from '../loans-account-stepper/loans-account-charges-step/loans-account-charges-step.component';
|
||||||
import { Dates } from 'app/core/utils/dates';
|
import { Dates } from 'app/core/utils/dates';
|
||||||
|
import { LoansAccountDatatableStepComponent } from '../loans-account-stepper/loans-account-datatable-step/loans-account-datatable-step.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create loans account
|
* Create loans account
|
||||||
@@ -27,6 +28,8 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
@ViewChild(LoansAccountDetailsStepComponent, { static: true }) loansAccountDetailsStep: LoansAccountDetailsStepComponent;
|
@ViewChild(LoansAccountDetailsStepComponent, { static: true }) loansAccountDetailsStep: LoansAccountDetailsStepComponent;
|
||||||
@ViewChild(LoansAccountTermsStepComponent, { static: true }) loansAccountTermsStep: LoansAccountTermsStepComponent;
|
@ViewChild(LoansAccountTermsStepComponent, { static: true }) loansAccountTermsStep: LoansAccountTermsStepComponent;
|
||||||
@ViewChild(LoansAccountChargesStepComponent, { static: true }) loansAccountChargesStep: LoansAccountChargesStepComponent;
|
@ViewChild(LoansAccountChargesStepComponent, { static: true }) loansAccountChargesStep: LoansAccountChargesStepComponent;
|
||||||
|
/** Get handle on dtloan tags in the template */
|
||||||
|
@ViewChildren('dtloan') clientDatatables: QueryList<LoansAccountDatatableStepComponent>;
|
||||||
|
|
||||||
/** Loans Account Template */
|
/** Loans Account Template */
|
||||||
loansAccountTemplate: any;
|
loansAccountTemplate: any;
|
||||||
@@ -38,6 +41,7 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
multiDisburseLoan: any;
|
multiDisburseLoan: any;
|
||||||
/** Principal Amount */
|
/** Principal Amount */
|
||||||
principal: any;
|
principal: any;
|
||||||
|
datatables: any = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets loans account create form.
|
* Sets loans account create form.
|
||||||
@@ -81,6 +85,16 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDatatables(): void {
|
||||||
|
this.datatables = [];
|
||||||
|
|
||||||
|
if (this.loansAccountTemplate.datatables) {
|
||||||
|
this.loansAccountTemplate.datatables.forEach((datatable: any) => {
|
||||||
|
this.datatables.push(datatable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Loans Account Details Form Data */
|
/** Get Loans Account Details Form Data */
|
||||||
get loansAccountDetailsForm() {
|
get loansAccountDetailsForm() {
|
||||||
return this.loansAccountDetailsStep.loansAccountDetailsForm;
|
return this.loansAccountDetailsStep.loansAccountDetailsForm;
|
||||||
@@ -124,6 +138,14 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate,
|
const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate,
|
||||||
this.loansAccountProductTemplate.calendarOptions, locale, dateFormat);
|
this.loansAccountProductTemplate.calendarOptions, locale, dateFormat);
|
||||||
|
|
||||||
|
if (this.loansAccountTemplate.datatables && this.loansAccountTemplate.datatables.length > 0) {
|
||||||
|
const datatables: any[] = [];
|
||||||
|
this.loansAccountTemplate.forEach((loanDatatable: LoansAccountDatatableStepComponent) => {
|
||||||
|
datatables.push(loanDatatable.payload);
|
||||||
|
});
|
||||||
|
payload['datatables'] = datatables;
|
||||||
|
}
|
||||||
|
|
||||||
this.loansService.createLoansAccount(payload).subscribe((response: any) => {
|
this.loansService.createLoansAccount(payload).subscribe((response: any) => {
|
||||||
this.router.navigate(['../', response.resourceId, 'general'], { relativeTo: this.route });
|
this.router.navigate(['../', response.resourceId, 'general'], { relativeTo: this.route });
|
||||||
});
|
});
|
||||||
|
|||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
<form [formGroup]="datatableForm">
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
|
||||||
|
|
||||||
|
<div *ngFor="let datatableInput of datatableInputs" fxFlex="48%">
|
||||||
|
<mat-form-field fxFlex="100%" *ngIf="!isBoolean(datatableInput.columnDisplayType)">
|
||||||
|
|
||||||
|
<mat-label>{{getInputName(datatableInput)}}</mat-label>
|
||||||
|
|
||||||
|
<mat-select *ngIf="isDropdown(datatableInput.columnDisplayType)" formControlName="{{datatableInput.controlName}}">
|
||||||
|
<mat-option *ngFor="let code of datatableInput.columnValues" [value]="code.id">
|
||||||
|
{{ code.value }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
|
||||||
|
<input matInput type="number" *ngIf="isNumeric(datatableInput.columnDisplayType)"
|
||||||
|
formControlName="{{datatableInput.controlName}}">
|
||||||
|
|
||||||
|
<input matInput *ngIf="isString(datatableInput.columnDisplayType)"
|
||||||
|
formControlName="{{datatableInput.controlName}}">
|
||||||
|
|
||||||
|
<textarea matInput *ngIf="isText(datatableInput.columnDisplayType)"
|
||||||
|
formControlName="{{datatableInput.controlName}}"></textarea>
|
||||||
|
|
||||||
|
<span *ngIf="isDate(datatableInput.columnDisplayType)" (click)="datePicker.open()">
|
||||||
|
<input matInput [matDatepicker]="datePicker" formControlName="{{datatableInput.controlName}}" class="date-picker">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="datePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #datePicker></mat-datepicker>
|
||||||
|
</span>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-checkbox *ngIf="isBoolean(datatableInput.columnDisplayType)" formControlName="{{datatableInput.controlName}}"
|
||||||
|
labelPosition="before" class="margin-v">
|
||||||
|
{{getInputName(datatableInput)}}
|
||||||
|
</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
|
||||||
|
<button mat-raised-button matStepperPrevious disabled>
|
||||||
|
<fa-icon icon="arrow-left"></fa-icon>
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
<button mat-raised-button matStepperNext>
|
||||||
|
Next
|
||||||
|
<fa-icon icon="arrow-right"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
.date-picker {
|
||||||
|
width: 92%;
|
||||||
|
}
|
||||||
|
|
||||||
|
mat-checkbox {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LoansAccountDatatableStepComponent } from './loans-account-datatable-step.component';
|
||||||
|
|
||||||
|
describe('LoansAccountDatatableStepComponent', () => {
|
||||||
|
let component: LoansAccountDatatableStepComponent;
|
||||||
|
let fixture: ComponentFixture<LoansAccountDatatableStepComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ LoansAccountDatatableStepComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(LoansAccountDatatableStepComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
+108
@@ -0,0 +1,108 @@
|
|||||||
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { Dates } from 'app/core/utils/dates';
|
||||||
|
import { SettingsService } from 'app/settings/settings.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-loans-account-datatable-step',
|
||||||
|
templateUrl: './loans-account-datatable-step.component.html',
|
||||||
|
styleUrls: ['./loans-account-datatable-step.component.scss']
|
||||||
|
})
|
||||||
|
export class LoansAccountDatatableStepComponent implements OnInit {
|
||||||
|
/** Input Fields Data */
|
||||||
|
@Input() datatableData: any;
|
||||||
|
/** Create Input Form */
|
||||||
|
datatableForm: FormGroup;
|
||||||
|
|
||||||
|
datatableInputs: any = [];
|
||||||
|
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private settingsService: SettingsService,
|
||||||
|
private dateUtils: Dates) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.datatableInputs = this.datatableData.columnHeaderData.filter((column: any) => {
|
||||||
|
return ((column.columnName !== 'id') && (column.columnName !== 'loan_id') && (column.columnName !== 'created_at') && (column.columnName !== 'updated_at'));
|
||||||
|
});
|
||||||
|
const inputItems: any = {};
|
||||||
|
this.datatableInputs.forEach((input: any) => {
|
||||||
|
input.controlName = this.getInputName(input);
|
||||||
|
if (!input.isColumnNullable) {
|
||||||
|
if (this.isNumeric(input.columnDisplayType)) {
|
||||||
|
inputItems[input.controlName] = new FormControl(0, [Validators.required]);
|
||||||
|
} else {
|
||||||
|
inputItems[input.controlName] = new FormControl('', [Validators.required]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputItems[input.controlName] = new FormControl('');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.datatableForm = this.formBuilder.group(inputItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
getInputName(datatableInput: any): string {
|
||||||
|
if (datatableInput.columnName && datatableInput.columnName.includes('_cd_')) {
|
||||||
|
return datatableInput.columnName.split('_cd_')[0];
|
||||||
|
}
|
||||||
|
return datatableInput.columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
isNumeric(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'INTEGER') || this.isColumnType(columnType, 'DECIMAL');
|
||||||
|
}
|
||||||
|
|
||||||
|
isDate(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'DATE') || this.isColumnType(columnType, 'DATETIME');
|
||||||
|
}
|
||||||
|
|
||||||
|
isBoolean(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'BOOLEAN');
|
||||||
|
}
|
||||||
|
|
||||||
|
isDropdown(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'CODELOOKUP');
|
||||||
|
}
|
||||||
|
|
||||||
|
isString(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'STRING');
|
||||||
|
}
|
||||||
|
|
||||||
|
isText(columnType: string) {
|
||||||
|
return this.isColumnType(columnType, 'TEXT');
|
||||||
|
}
|
||||||
|
|
||||||
|
isColumnType(columnType: string, expectedType: string) {
|
||||||
|
return (columnType === expectedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
get payload(): any {
|
||||||
|
const dateFormat = this.settingsService.dateFormat;
|
||||||
|
const datatableDataValues = this.datatableForm.value;
|
||||||
|
const data = {
|
||||||
|
locale: this.settingsService.language.code
|
||||||
|
};
|
||||||
|
let existDate = false;
|
||||||
|
this.datatableInputs.forEach((input: any) => {
|
||||||
|
const controlName = this.getInputName(input);
|
||||||
|
if (this.isNumeric(input.columnDisplayType)) {
|
||||||
|
data[input.columnName] = datatableDataValues[controlName] * 1;
|
||||||
|
} else if (this.isDate(input.columnDisplayType)) {
|
||||||
|
data[input.columnName] = this.dateUtils.formatDate(datatableDataValues[controlName], dateFormat);
|
||||||
|
existDate = true;
|
||||||
|
} else {
|
||||||
|
data[input.columnName] = datatableDataValues[controlName];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existDate) {
|
||||||
|
data['dateFormat'] = dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
registeredTableName: this.datatableData.registeredTableName,
|
||||||
|
data: data
|
||||||
|
};
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Pay Charge" *ngIf="charge.chargePayable && status=='Active'"
|
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Pay Charge" *ngIf="charge.chargePayable && !charge.paid && status=='Active'"
|
||||||
(click)="routeEdit($event); payCharge(charge.id)">
|
(click)="routeEdit($event); payCharge(charge.id)">
|
||||||
<i class="fa fa-dollar"></i>
|
<i class="fa fa-dollar"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -84,15 +84,8 @@ export class ChargesTabComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
payCharge(chargeId: any) {
|
payCharge(chargeId: any) {
|
||||||
const formfields: FormfieldBase[] = [
|
const formfields: FormfieldBase[] = [
|
||||||
new InputBase({
|
|
||||||
controlName: 'amount',
|
|
||||||
label: 'Amount',
|
|
||||||
value: '',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
}),
|
|
||||||
new DatepickerBase({
|
new DatepickerBase({
|
||||||
controlName: 'dueDate',
|
controlName: 'transactionDate',
|
||||||
label: 'Payment Date',
|
label: 'Payment Date',
|
||||||
value: '',
|
value: '',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
@@ -107,15 +100,15 @@ export class ChargesTabComponent implements OnInit {
|
|||||||
const payChargeDialogRef = this.dialog.open(FormDialogComponent, { data });
|
const payChargeDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
payChargeDialogRef.afterClosed().subscribe((response: any) => {
|
payChargeDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
const locale = 'en';
|
const locale = this.settingsService.language.code;
|
||||||
const dateFormat = this.settingsService.dateFormat;
|
const dateFormat = this.settingsService.dateFormat;
|
||||||
|
const prevTransactionDate: Date = response.data.value.transactionDate;
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
...response.data.value,
|
transactionDate: this.dateUtils.formatDate(prevTransactionDate, dateFormat),
|
||||||
dueDate: this.dateUtils.formatDate(response.data.value.dueDate, dateFormat),
|
|
||||||
dateFormat,
|
dateFormat,
|
||||||
locale
|
locale
|
||||||
};
|
};
|
||||||
this.loansService.executeLoansAccountChargesCommand(this.loanDetails.id, 'paycharge', dataObject, chargeId)
|
this.loansService.executeLoansAccountChargesCommand(this.loanDetails.id, 'pay', dataObject, chargeId)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.reload();
|
this.reload();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,52 +1,7 @@
|
|||||||
<div class="tab-container mat-typography">
|
<mifosx-entity-documents-tab [entityType]="entityType" [entityId]="entityId"
|
||||||
|
[entityDocuments]="entityDocuments"
|
||||||
<h3>Documents</h3>
|
[callbackUpload]="uploadDocument"
|
||||||
|
[callbackDownload]="downloadDocument"
|
||||||
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()"
|
[callbackDelete]="deleteDocument"
|
||||||
*mifosxHasPermission="'CREATE_DOCUMENT'">
|
>
|
||||||
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
|
</mifosx-entity-documents-tab>
|
||||||
</button>
|
|
||||||
|
|
||||||
<table mat-table #documentsTable [dataSource]="dataSource" matSort>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{ document.name }} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="description">
|
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Description </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{ document.description }} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="filename">
|
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> File Name </th>
|
|
||||||
<td mat-cell *matCellDef="let document"> {{ document.fileName }} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Actions </th>
|
|
||||||
<td mat-cell *matCellDef="let document; let index">
|
|
||||||
<button class="document-action-button" mat-raised-button color="primary">
|
|
||||||
<fa-icon icon="cloud-download-alt"></fa-icon>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button class="document-action-button" mat-raised-button color="primary" *ngIf="document.fileIsImage">
|
|
||||||
<i class="fa fa-eye"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button class="document-action-button" mat-raised-button color="warn"
|
|
||||||
(click)="deleteDocument(document.id, index)">
|
|
||||||
<fa-icon icon="times"></fa-icon>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
|
||||||
import { MatSort } from '@angular/material/sort';
|
|
||||||
import { MatTableDataSource, MatTable } from '@angular/material/table';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { LoansService } from 'app/loans/loans.service';
|
import { LoansService } from 'app/loans/loans.service';
|
||||||
|
|
||||||
/** Dialog Components */
|
|
||||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
|
||||||
import { SettingsService } from 'app/settings/settings.service';
|
import { SettingsService } from 'app/settings/settings.service';
|
||||||
import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-dialogs/upload-document-dialog/upload-document-dialog.component';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overdue charges tab component
|
* Overdue charges tab component
|
||||||
@@ -24,26 +16,12 @@ import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-d
|
|||||||
styleUrls: ['./loan-documents-tab.component.scss']
|
styleUrls: ['./loan-documents-tab.component.scss']
|
||||||
})
|
})
|
||||||
export class LoanDocumentsTabComponent implements OnInit {
|
export class LoanDocumentsTabComponent implements OnInit {
|
||||||
@ViewChild('documentsTable', { static: true }) documentsTable: MatTable<Element>;
|
|
||||||
|
|
||||||
/** Stores the resolved loan documents data */
|
/** Stores the resolved loan documents data */
|
||||||
loanDocuments: any;
|
entityDocuments: any;
|
||||||
/** Stores the resolved loan details data */
|
/** Loan account Id */
|
||||||
loanDetailsData: any;
|
entityId: string;
|
||||||
/** Status of the loan account */
|
entityType: string = 'loans';
|
||||||
status: any;
|
|
||||||
/** Choice */
|
|
||||||
choice: boolean;
|
|
||||||
|
|
||||||
/** Columns to be displayed in loan documents table. */
|
|
||||||
displayedColumns: string[] = ['name', 'description', 'filename', 'actions'];
|
|
||||||
/** Data source for loan documents table. */
|
|
||||||
dataSource: MatTableDataSource<any>;
|
|
||||||
|
|
||||||
/** Paginator for codes table. */
|
|
||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
|
||||||
/** Sorter for codes table. */
|
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the loans data from `resolve`.
|
* Retrieves the loans data from `resolve`.
|
||||||
@@ -51,31 +29,19 @@ export class LoanDocumentsTabComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private loansService: LoansService,
|
private loansService: LoansService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService) {
|
||||||
public dialog: MatDialog) {
|
this.entityId = this.route.parent.snapshot.params['loanId'];
|
||||||
|
|
||||||
this.route.data.subscribe((data: { loanDocuments: any }) => {
|
this.route.data.subscribe((data: { loanDocuments: any }) => {
|
||||||
this.getLoanDocumentsData(data.loanDocuments);
|
this.getLoanDocumentsData(data.loanDocuments);
|
||||||
});
|
});
|
||||||
this.route.parent.data.subscribe((data: { loanDetailsData: any }) => {
|
|
||||||
this.loanDetailsData = data.loanDetailsData;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() { }
|
||||||
this.status = this.loanDetailsData.status.value;
|
|
||||||
if (this.status === 'Submitted and pending approval' || this.status === 'Active' || this.status === 'Approved') {
|
|
||||||
this.choice = true;
|
|
||||||
}
|
|
||||||
this.dataSource = new MatTableDataSource(this.loanDocuments);
|
|
||||||
this.dataSource.paginator = this.paginator;
|
|
||||||
this.dataSource.sort = this.sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLoanDocumentsData(data: any) {
|
getLoanDocumentsData(data: any) {
|
||||||
data.forEach((ele: any) => {
|
data.forEach((ele: any) => {
|
||||||
let loandocs = {};
|
ele.docUrl = this.settingsService.serverUrl + '/loans/' + ele.parentEntityId + '/documents/' + ele.id + '/attachment?tenantIdentifier=' + environment.fineractPlatformTenantId;
|
||||||
loandocs = this.settingsService.serverUrl + '/loans/' + ele.parentEntityId + '/documents/' + ele.id + '/attachment?tenantIdentifier=' + environment.fineractPlatformTenantId;
|
|
||||||
ele.docUrl = loandocs;
|
|
||||||
if (ele.fileName) {
|
if (ele.fileName) {
|
||||||
if (ele.fileName.toLowerCase().indexOf('.jpg') !== -1 || ele.fileName.toLowerCase().indexOf('.jpeg') !== -1 || ele.fileName.toLowerCase().indexOf('.png') !== -1) {
|
if (ele.fileName.toLowerCase().indexOf('.jpg') !== -1 || ele.fileName.toLowerCase().indexOf('.jpeg') !== -1 || ele.fileName.toLowerCase().indexOf('.png') !== -1) {
|
||||||
ele.fileIsImage = true;
|
ele.fileIsImage = true;
|
||||||
@@ -87,46 +53,22 @@ export class LoanDocumentsTabComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.loanDocuments = data;
|
this.entityDocuments = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadDocument() {
|
downloadDocument(documentId: string) {
|
||||||
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
|
this.loansService.downloadLoanDocument(this.entityId, documentId).subscribe(res => {
|
||||||
data: { documentIdentifier: false, entityType: 'Loan' }
|
const url = window.URL.createObjectURL(res);
|
||||||
});
|
window.open(url);
|
||||||
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
|
||||||
if (dialogResponse) {
|
|
||||||
const formData: FormData = new FormData;
|
|
||||||
formData.append('name', dialogResponse.fileName);
|
|
||||||
formData.append('file', dialogResponse.file);
|
|
||||||
formData.append('description', dialogResponse.description);
|
|
||||||
this.loansService.loadLoanDocument(this.loanDetailsData.id, formData).subscribe((res: any) => {
|
|
||||||
this.loanDocuments.push({
|
|
||||||
id: res.resourceId,
|
|
||||||
parentEntityType: 'loans',
|
|
||||||
parentEntityId: this.loanDetailsData.id,
|
|
||||||
name: dialogResponse.fileName,
|
|
||||||
description: dialogResponse.description,
|
|
||||||
fileName: dialogResponse.file.name
|
|
||||||
});
|
|
||||||
this.documentsTable.renderRows();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteDocument(documentId: any, index: any) {
|
uploadDocument(formData: FormData): any {
|
||||||
const deleteDocumentDialogRef = this.dialog.open(DeleteDialogComponent, {
|
return this.loansService.loadLoanDocument(this.entityId, formData);
|
||||||
data: { deleteContext: `document id:${documentId}` }
|
}
|
||||||
});
|
|
||||||
deleteDocumentDialogRef.afterClosed().subscribe((response: any) => {
|
deleteDocument(documentId: any) {
|
||||||
if (response.delete) {
|
this.loansService.deleteLoanDocument(this.entityId, documentId).subscribe((res: any) => {});
|
||||||
this.loansService.deleteLoanDocument(this.loanDetailsData.id, documentId).subscribe((res: any) => {
|
|
||||||
this.loanDocuments.splice(index, 1);
|
|
||||||
this.documentsTable.renderRows();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class LoansViewComponent implements OnInit {
|
|||||||
this.recalculateInterest = this.loanDetailsData.recalculateInterest || true;
|
this.recalculateInterest = this.loanDetailsData.recalculateInterest || true;
|
||||||
this.status = this.loanDetailsData.status.value;
|
this.status = this.loanDetailsData.status.value;
|
||||||
if (this.loanDetailsData.status.active && this.loanDetailsData.multiDisburseLoan) {
|
if (this.loanDetailsData.status.active && this.loanDetailsData.multiDisburseLoan) {
|
||||||
if (this.loanDetailsData) {
|
if (this.loanDetailsData && this.loanDetailsData.transactions) {
|
||||||
this.loanDetailsData.transactions.forEach((transaction: any) => {
|
this.loanDetailsData.transactions.forEach((transaction: any) => {
|
||||||
if (transaction.type.disbursement) {
|
if (transaction.type.disbursement) {
|
||||||
this.disburseTransactionNo++;
|
this.disburseTransactionNo++;
|
||||||
|
|||||||
@@ -1,32 +1,7 @@
|
|||||||
<div class="tab-container mat-typography">
|
<mifosx-entity-notes-tab [entityId]="entityId"
|
||||||
<h3>Notes</h3>
|
[entityNotes]="entityNotes"
|
||||||
<div>
|
[callbackAdd]="addNote"
|
||||||
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
[callbackEdit]="editNote"
|
||||||
(ngSubmit)="submit()">
|
[callbackDelete]="deleteNote"
|
||||||
<mat-form-field fxFlex="calc(90%-20px)">
|
>
|
||||||
<textarea formControlName="note" matInput placeholder="Write a note ...."></textarea>
|
</mifosx-entity-notes-tab>
|
||||||
</mat-form-field>
|
|
||||||
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid">
|
|
||||||
<fa-icon icon="plus"></fa-icon> Add
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<mat-list>
|
|
||||||
<mat-list-item *ngFor="let loanNote of loanNotes; let i=index;">
|
|
||||||
<fa-icon icon="sticky-note" matListIcon></fa-icon>
|
|
||||||
<h3 matLine>{{loanNote.note}} </h3>
|
|
||||||
<p matLine>
|
|
||||||
<span>Created by: {{loanNote.createdByUsername}}</span><br />
|
|
||||||
<span>Date: {{loanNote.createdOn | dateFormat}}</span>
|
|
||||||
</p>
|
|
||||||
<div fxLayout="row" fxLayoutAlign="flex-start">
|
|
||||||
<button mat-button color="primary" (click)="editNote(loanNote.id,loanNote.note,i)">
|
|
||||||
<fa-icon icon="edit"></fa-icon>
|
|
||||||
</button>
|
|
||||||
<button mat-button color="warn" (click)="deleteNote(loanNote.id,i)">
|
|
||||||
<fa-icon icon="trash"></fa-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</mat-list-item>
|
|
||||||
</mat-list>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
.tab-container {
|
|
||||||
padding: 1%;
|
|
||||||
margin: 1%;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|
||||||
|
|
||||||
/** Custom Components */
|
/** Custom Components */
|
||||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
|
||||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
|
||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { LoansService } from '../../loans.service';
|
import { LoansService } from '../../loans.service';
|
||||||
@@ -18,84 +14,44 @@ import { AuthenticationService } from '../../../core/authentication/authenticati
|
|||||||
})
|
})
|
||||||
export class NotesTabComponent implements OnInit {
|
export class NotesTabComponent implements OnInit {
|
||||||
|
|
||||||
loanId: string;
|
entityId: string;
|
||||||
username: string;
|
username: string;
|
||||||
loanNotes: any;
|
entityNotes: any;
|
||||||
noteForm: FormGroup;
|
|
||||||
@ViewChild('formRef', { static: true }) formRef: any;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
private loansService: LoansService,
|
private loansService: LoansService,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService) {
|
||||||
private dialog: MatDialog) {
|
|
||||||
const savedCredentials = this.authenticationService.getCredentials();
|
const savedCredentials = this.authenticationService.getCredentials();
|
||||||
this.username = savedCredentials.username;
|
this.username = savedCredentials.username;
|
||||||
this.loanId = this.route.parent.snapshot.params['loanId'];
|
this.entityId = this.route.parent.snapshot.params['loanId'];
|
||||||
this.route.data.subscribe((data: { loanNotes: any }) => {
|
this.route.data.subscribe((data: { loanNotes: any }) => {
|
||||||
this.loanNotes = data.loanNotes;
|
this.entityNotes = data.loanNotes;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() { }
|
||||||
this.createNoteForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
createNoteForm() {
|
addNote(noteContent: any) {
|
||||||
this.noteForm = this.formBuilder.group({
|
this.loansService.createLoanNote(this.entityId, noteContent).subscribe((response: any) => {
|
||||||
'note': ['', Validators.required]
|
this.entityNotes.push({
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
submit() {
|
|
||||||
this.loansService.createLoanNote(this.loanId, this.noteForm.value).subscribe((response: any) => {
|
|
||||||
this.loanNotes.push({
|
|
||||||
id: response.resourceId,
|
id: response.resourceId,
|
||||||
createdByUsername: this.username,
|
createdByUsername: this.username,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
note: this.noteForm.value.note
|
note: noteContent.note
|
||||||
});
|
});
|
||||||
this.formRef.resetForm();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
editNote(noteId: string, noteContent: string, index: number) {
|
editNote(noteId: string, noteContent: any, index: number) {
|
||||||
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
|
this.loansService.editLoanNote(this.entityId, noteId, noteContent).subscribe(() => {
|
||||||
data: { formfields: [{
|
this.entityNotes[index].note = noteContent.note;
|
||||||
controlName: 'note',
|
|
||||||
required: true,
|
|
||||||
value: noteContent,
|
|
||||||
controlType: 'input',
|
|
||||||
label: 'Note'
|
|
||||||
}],
|
|
||||||
layout: {
|
|
||||||
columns: 1,
|
|
||||||
addButtonText: 'Confirm'
|
|
||||||
},
|
|
||||||
title: 'Edit Note'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
editNoteDialogRef.afterClosed().subscribe((response: any) => {
|
|
||||||
if (response.data) {
|
|
||||||
this.loansService.editLoanNote(this.loanId, noteId, response.data.value).subscribe(() => {
|
|
||||||
this.loanNotes[index].note = response.data.value.note;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteNote(noteId: string, index: number) {
|
deleteNote(noteId: string, index: number) {
|
||||||
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
|
this.loansService.deleteLoanNote(this.entityId, noteId)
|
||||||
data: { deleteContext: `Note id:${noteId}` }
|
.subscribe(() => {
|
||||||
});
|
this.entityNotes.splice(index, 1);
|
||||||
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
|
|
||||||
if (response.delete) {
|
|
||||||
this.loansService.deleteLoanNote(this.loanId, noteId)
|
|
||||||
.subscribe(() => {
|
|
||||||
this.loanNotes.splice(index, 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
|
||||||
<div fxLayout="row wrap" class="content">
|
<div fxLayout="row wrap" class="content">
|
||||||
|
<div fxFlex="100%" [ngClass]="loanChargeColor()">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div fxFlex="50%" class="mat-body-strong">
|
<div fxFlex="50%" class="mat-body-strong">
|
||||||
Name
|
Name
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
@import "assets/styles/helper";
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 37rem;
|
max-width: 37rem;
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
div {
|
div {
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
@@ -8,3 +10,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paid {
|
||||||
|
background-color: $status-active;
|
||||||
|
height: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-paid {
|
||||||
|
background-color: $status-active-overdue;
|
||||||
|
height: 4px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class ViewChargeComponent {
|
|||||||
private settingsService: SettingsService) {
|
private settingsService: SettingsService) {
|
||||||
this.route.data.subscribe((data: { loansAccountCharge: any, loanDetailsData: any }) => {
|
this.route.data.subscribe((data: { loansAccountCharge: any, loanDetailsData: any }) => {
|
||||||
this.chargeData = data.loansAccountCharge;
|
this.chargeData = data.loansAccountCharge;
|
||||||
this.allowPayCharge = (this.chargeData.chargeTimeType.code === 'chargeTimeType.instalmentFee');
|
this.allowPayCharge = (this.chargeData.chargePayable && !this.chargeData.paid);
|
||||||
this.allowWaive = !this.chargeData.chargeTimeType.waived;
|
this.allowWaive = !this.chargeData.chargeTimeType.waived;
|
||||||
this.loansAccountData = data.loanDetailsData;
|
this.loansAccountData = data.loanDetailsData;
|
||||||
});
|
});
|
||||||
@@ -72,7 +72,7 @@ export class ViewChargeComponent {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
const data = {
|
const data = {
|
||||||
title: 'Pay Charge',
|
title: `Pay Charge ${this.chargeData.id}`,
|
||||||
layout: { addButtonText: 'Confirm' },
|
layout: { addButtonText: 'Confirm' },
|
||||||
formfields: formfields
|
formfields: formfields
|
||||||
};
|
};
|
||||||
@@ -173,6 +173,10 @@ export class ViewChargeComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loanChargeColor(): string {
|
||||||
|
return this.chargeData.paid ? 'paid' : 'not-paid';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refetches data fot the component
|
* Refetches data fot the component
|
||||||
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
|
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import { LoanDelinquencyTagsTabComponent } from './loans-view/loan-delinquency-t
|
|||||||
import { LoansAccountScheduleStepComponent } from './loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component';
|
import { LoansAccountScheduleStepComponent } from './loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component';
|
||||||
import { EditRepaymentScheduleComponent } from './loans-view/loan-account-actions/edit-repayment-schedule/edit-repayment-schedule.component';
|
import { EditRepaymentScheduleComponent } from './loans-view/loan-account-actions/edit-repayment-schedule/edit-repayment-schedule.component';
|
||||||
import { DisburseToSavingsAccountComponent } from './loans-view/loan-account-actions/disburse-to-savings-account/disburse-to-savings-account.component';
|
import { DisburseToSavingsAccountComponent } from './loans-view/loan-account-actions/disburse-to-savings-account/disburse-to-savings-account.component';
|
||||||
|
import { LoansAccountDatatableStepComponent } from './loans-account-stepper/loans-account-datatable-step/loans-account-datatable-step.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loans Module
|
* Loans Module
|
||||||
@@ -144,7 +145,8 @@ import { DisburseToSavingsAccountComponent } from './loans-view/loan-account-act
|
|||||||
LoanDelinquencyTagsTabComponent,
|
LoanDelinquencyTagsTabComponent,
|
||||||
LoansAccountScheduleStepComponent,
|
LoansAccountScheduleStepComponent,
|
||||||
EditRepaymentScheduleComponent,
|
EditRepaymentScheduleComponent,
|
||||||
DisburseToSavingsAccountComponent
|
DisburseToSavingsAccountComponent,
|
||||||
|
LoansAccountDatatableStepComponent
|
||||||
],
|
],
|
||||||
providers: [ ],
|
providers: [ ],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -322,6 +322,10 @@ export class LoansService {
|
|||||||
return this.http.get(`/loans/${loanId}/documents`);
|
return this.http.get(`/loans/${loanId}/documents`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadLoanDocument(parentEntityId: string, documentId: string) {
|
||||||
|
return this.http.get(`/loans/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' });
|
||||||
|
}
|
||||||
|
|
||||||
deleteLoanDocument(loanId: any, documentId: any): Observable<any> {
|
deleteLoanDocument(loanId: any, documentId: any): Observable<any> {
|
||||||
return this.http.delete(`/loans/${loanId}/documents/${documentId}`);
|
return this.http.delete(`/loans/${loanId}/documents/${documentId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { SavingDocumentsResolver } from './saving-documents.resolver';
|
||||||
|
|
||||||
|
describe('SavingDocumentsResolver', () => {
|
||||||
|
let resolver: SavingDocumentsResolver;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
resolver = TestBed.inject(SavingDocumentsResolver);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(resolver).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {
|
||||||
|
Resolve,
|
||||||
|
ActivatedRouteSnapshot
|
||||||
|
} from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { SavingsService } from '../savings.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class SavingDocumentsResolver implements Resolve<boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SavingsService} savingsService Savings service.
|
||||||
|
*/
|
||||||
|
constructor(private savingsService: SavingsService) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Savings data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
const savingAccountId = route.parent.paramMap.get('savingAccountId');
|
||||||
|
return this.savingsService.getSavingsDocuments(savingAccountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { SavingNotesResolver } from './saving-notes.resolver';
|
||||||
|
|
||||||
|
describe('SavingNotesResolver', () => {
|
||||||
|
let resolver: SavingNotesResolver;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
resolver = TestBed.inject(SavingNotesResolver);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(resolver).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {
|
||||||
|
Resolve,
|
||||||
|
ActivatedRouteSnapshot
|
||||||
|
} from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { SavingsService } from '../savings.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class SavingNotesResolver implements Resolve<boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SavingsService} savingsService Savings service.
|
||||||
|
*/
|
||||||
|
constructor(private savingsService: SavingsService) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Savings data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
const savingAccountId = route.parent.paramMap.get('savingAccountId');
|
||||||
|
return this.savingsService.getSavingsNotes(savingAccountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -135,7 +135,7 @@ export class ChargesTabComponent implements OnInit {
|
|||||||
dateFormat,
|
dateFormat,
|
||||||
locale
|
locale
|
||||||
};
|
};
|
||||||
this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'paycharge', dataObject, chargeId)
|
this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'pay', dataObject, chargeId)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.reload();
|
this.reload();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<mifosx-entity-notes-tab [entityId]="entityId"
|
||||||
|
[entityNotes]="entityNotes"
|
||||||
|
[callbackAdd]="addNote"
|
||||||
|
[callbackEdit]="editNote"
|
||||||
|
[callbackDelete]="deleteNote"
|
||||||
|
>
|
||||||
|
</mifosx-entity-notes-tab>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NotesTabComponent } from './notes-tab.component';
|
||||||
|
|
||||||
|
describe('NotesTabComponent', () => {
|
||||||
|
let component: NotesTabComponent;
|
||||||
|
let fixture: ComponentFixture<NotesTabComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ NotesTabComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(NotesTabComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { AuthenticationService } from 'app/core/authentication/authentication.service';
|
||||||
|
import { SavingsService } from 'app/savings/savings.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-notes-tab',
|
||||||
|
templateUrl: './notes-tab.component.html',
|
||||||
|
styleUrls: ['./notes-tab.component.scss']
|
||||||
|
})
|
||||||
|
export class NotesTabComponent implements OnInit {
|
||||||
|
|
||||||
|
entityId: string;
|
||||||
|
username: string;
|
||||||
|
entityNotes: any;
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private savingsService: SavingsService,
|
||||||
|
private authenticationService: AuthenticationService) {
|
||||||
|
const savedCredentials = this.authenticationService.getCredentials();
|
||||||
|
this.username = savedCredentials.username;
|
||||||
|
this.entityId = this.route.parent.snapshot.params['savingAccountId'];
|
||||||
|
this.route.data.subscribe((data: { savingAccountNotes: any }) => {
|
||||||
|
this.entityNotes = data.savingAccountNotes;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
addNote(noteContent: any) {
|
||||||
|
this.savingsService.createSavingsNote(this.entityId, noteContent).subscribe((response: any) => {
|
||||||
|
this.entityNotes.push({
|
||||||
|
id: response.resourceId,
|
||||||
|
createdByUsername: this.username,
|
||||||
|
createdOn: new Date(),
|
||||||
|
note: noteContent
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
editNote(noteId: string, noteContent: any, index: number) {
|
||||||
|
this.savingsService.editSavingsNote(this.entityId, noteId, noteContent).subscribe(() => {
|
||||||
|
this.entityNotes[index].note = noteContent.note;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteNote(noteId: string, index: number) {
|
||||||
|
this.savingsService.deleteSavingsNote(this.entityId, noteId)
|
||||||
|
.subscribe(() => {
|
||||||
|
this.entityNotes.splice(index, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,10 +34,10 @@
|
|||||||
{{entityType}} Name: {{savingsAccountData.clientName || savingsAccountData.groupName}}
|
{{entityType}} Name: {{savingsAccountData.clientName || savingsAccountData.groupName}}
|
||||||
<span class="m-l-10" *ngIf="savingsAccountData.clientAccountNo">({{savingsAccountData.clientAccountNo}})</span><br />
|
<span class="m-l-10" *ngIf="savingsAccountData.clientAccountNo">({{savingsAccountData.clientAccountNo}})</span><br />
|
||||||
<span *ngIf="!savingsAccountData.status.rejected && !savingsAccountData.status.submittedAndPendingApproval">
|
<span *ngIf="!savingsAccountData.status.rejected && !savingsAccountData.status.submittedAndPendingApproval">
|
||||||
Current Balances:
|
Current Balances :
|
||||||
{{savingsAccountData.currency.displaySymbol}}<span class="m-l-10">{{savingsAccountData.summary.accountBalance |
|
{{savingsAccountData.currency.displaySymbol}}<span class="m-l-10">{{savingsAccountData.summary.accountBalance |
|
||||||
number}}</span><br />
|
number}}</span><br />
|
||||||
Available Balance:
|
Available Balance :
|
||||||
{{savingsAccountData.currency.displaySymbol}}<span class="m-l-10">{{savingsAccountData.summary.availableBalance |
|
{{savingsAccountData.currency.displaySymbol}}<span class="m-l-10">{{savingsAccountData.summary.availableBalance |
|
||||||
number}}</span>
|
number}}</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -310,6 +310,14 @@
|
|||||||
[active]="charges.isActive">
|
[active]="charges.isActive">
|
||||||
Charges
|
Charges
|
||||||
</a>
|
</a>
|
||||||
|
<a mat-tab-link [routerLink]="['./documents']" routerLinkActive #savingsDocuments="routerLinkActive"
|
||||||
|
[active]="savingsDocuments.isActive">
|
||||||
|
Savings Documents
|
||||||
|
</a>
|
||||||
|
<a mat-tab-link *mifosxHasPermission="'READ_SAVINGSNOTE'" [routerLink]="['./notes']" routerLinkActive #notes="routerLinkActive"
|
||||||
|
[active]="notes.isActive">
|
||||||
|
Notes
|
||||||
|
</a>
|
||||||
<ng-container *mifosxHasPermission="'READ_SAVINGSACCOUNTCHARGE'">
|
<ng-container *mifosxHasPermission="'READ_SAVINGSACCOUNTCHARGE'">
|
||||||
<a mat-tab-link [routerLink]="['./standing-instructions']" routerLinkActive
|
<a mat-tab-link [routerLink]="['./standing-instructions']" routerLinkActive
|
||||||
#standingInstructions="routerLinkActive" [active]="standingInstructions.isActive"
|
#standingInstructions="routerLinkActive" [active]="standingInstructions.isActive"
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<mifosx-entity-documents-tab [entityType]="entityType" [entityId]="entityId"
|
||||||
|
[entityDocuments]="entityDocuments"
|
||||||
|
[callbackUpload]="uploadDocument"
|
||||||
|
[callbackDownload]="downloadDocument"
|
||||||
|
[callbackDelete]="deleteDocument"
|
||||||
|
>
|
||||||
|
</mifosx-entity-documents-tab>
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { SavingsDocumentsTabComponent } from './savings-documents-tab.component';
|
||||||
|
|
||||||
|
describe('SavingsDocumentsTabComponent', () => {
|
||||||
|
let component: SavingsDocumentsTabComponent;
|
||||||
|
let fixture: ComponentFixture<SavingsDocumentsTabComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ SavingsDocumentsTabComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(SavingsDocumentsTabComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-dialogs/upload-document-dialog/upload-document-dialog.component';
|
||||||
|
import { SavingsService } from 'app/savings/savings.service';
|
||||||
|
import { SettingsService } from 'app/settings/settings.service';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-savings-documents-tab',
|
||||||
|
templateUrl: './savings-documents-tab.component.html',
|
||||||
|
styleUrls: ['./savings-documents-tab.component.scss']
|
||||||
|
})
|
||||||
|
export class SavingsDocumentsTabComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Stores the resolved savings documents data */
|
||||||
|
entityDocuments: any;
|
||||||
|
/** Stores the saving Account Id */
|
||||||
|
entityId: string;
|
||||||
|
entityType: string = 'savings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the savings data from `resolve`.
|
||||||
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
*/
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private savingsService: SavingsService,
|
||||||
|
private settingsService: SettingsService,
|
||||||
|
public dialog: MatDialog) {
|
||||||
|
this.route.data.subscribe((data: { savingsDocuments: any }) => {
|
||||||
|
this.setSavingsDocumentsData(data.savingsDocuments);
|
||||||
|
});
|
||||||
|
this.entityId = this.route.parent.snapshot.params['savingAccountId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSavingsDocumentsData(data: any) {
|
||||||
|
data.forEach((ele: any) => {
|
||||||
|
ele.docUrl = this.settingsService.serverUrl + '/savings/' + ele.parentEntityId + '/documents/' + ele.id + '/attachment?tenantIdentifier=' + environment.fineractPlatformTenantId;
|
||||||
|
if (ele.fileName) {
|
||||||
|
if (ele.fileName.toLowerCase().indexOf('.jpg') !== -1 || ele.fileName.toLowerCase().indexOf('.jpeg') !== -1 || ele.fileName.toLowerCase().indexOf('.png') !== -1) {
|
||||||
|
ele.fileIsImage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ele.type) {
|
||||||
|
if (ele.type.toLowerCase().indexOf('image') !== -1) {
|
||||||
|
ele.fileIsImage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.entityDocuments = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadDocument(parentEntityId: string, documentId: string) {
|
||||||
|
this.savingsService.downloadSavingsDocument(parentEntityId, documentId).subscribe(res => {
|
||||||
|
const url = window.URL.createObjectURL(res);
|
||||||
|
window.open(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadDocument(formData: FormData): any {
|
||||||
|
return this.savingsService.loadSavingsDocument(this.entityId, formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteDocument(documentId: any) {
|
||||||
|
this.savingsService.deleteSavingsDocument(this.entityId, documentId).subscribe((res: any) => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -93,7 +93,7 @@ export class ViewChargeComponent {
|
|||||||
dateFormat,
|
dateFormat,
|
||||||
locale
|
locale
|
||||||
};
|
};
|
||||||
this.savingsService.executeSavingsAccountChargesCommand(this.chargeData.accountId, 'paycharge', dataObject, this.chargeData.id)
|
this.savingsService.executeSavingsAccountChargesCommand(this.chargeData.accountId, 'pay', dataObject, this.chargeData.id)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.reload();
|
this.reload();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ import { GSIMAccountsResolver } from 'app/groups/common-resolvers/gsim-account-r
|
|||||||
import { GroupAccountsResolver } from 'app/groups/common-resolvers/group-account.resolver';
|
import { GroupAccountsResolver } from 'app/groups/common-resolvers/group-account.resolver';
|
||||||
import { GSIMViewResolver } from './gsim-account/gsim-account.resolver';
|
import { GSIMViewResolver } from './gsim-account/gsim-account.resolver';
|
||||||
import { GroupViewResolver } from 'app/groups/common-resolvers/group-view.resolver';
|
import { GroupViewResolver } from 'app/groups/common-resolvers/group-view.resolver';
|
||||||
|
import { SavingsDocumentsTabComponent } from './savings-account-view/savings-documents-tab/savings-documents-tab.component';
|
||||||
|
import { NotesTabComponent } from './savings-account-view/notes-tab/notes-tab.component';
|
||||||
|
import { SavingNotesResolver } from './common-resolvers/saving-notes.resolver';
|
||||||
|
import { SavingDocumentsResolver } from './common-resolvers/saving-documents.resolver';
|
||||||
|
import { DocumentsTabComponent } from 'app/clients/clients-view/documents-tab/documents-tab.component';
|
||||||
/** Savings Routes */
|
/** Savings Routes */
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -91,6 +96,22 @@ const routes: Routes = [
|
|||||||
component: StandingInstructionsTabComponent,
|
component: StandingInstructionsTabComponent,
|
||||||
data: { title: extract('Savings Account SIH'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false }
|
data: { title: extract('Savings Account SIH'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'notes',
|
||||||
|
component: NotesTabComponent,
|
||||||
|
data: { title: extract('Savings Account Notes'), breadcrumb: 'Notes', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
savingAccountNotes: SavingNotesResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'documents',
|
||||||
|
component: DocumentsTabComponent,
|
||||||
|
data: { title: extract('Savings Account Documents'), breadcrumb: 'Documents', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
savingAccountDocuments: SavingDocumentsResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'datatables',
|
path: 'datatables',
|
||||||
children: [
|
children: [
|
||||||
@@ -184,6 +205,26 @@ const routes: Routes = [
|
|||||||
savingsAccountActionData: SavingsAccountActionsResolver
|
savingsAccountActionData: SavingsAccountActionsResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'documents',
|
||||||
|
data: { title: extract('Savings Account Documents'), breadcrumb: 'Documents', routeParamBreadcrumb: false },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
redirectTo: '../documents', pathMatch: 'prefix'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'notes',
|
||||||
|
data: { title: extract('Savings Account Notes'), breadcrumb: 'Notes', routeParamBreadcrumb: false },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
redirectTo: '../notes', pathMatch: 'prefix'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'transfer-funds',
|
path: 'transfer-funds',
|
||||||
loadChildren: () => import('../account-transfers/account-transfers.module').then(m => m.AccountTransfersModule)
|
loadChildren: () => import('../account-transfers/account-transfers.module').then(m => m.AccountTransfersModule)
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ import { GsimAccountComponent } from './gsim-account/gsim-account.component';
|
|||||||
import { CreateGsimAccountComponent } from './gsim-account/create-gsim-account/create-gsim-account.component';
|
import { CreateGsimAccountComponent } from './gsim-account/create-gsim-account/create-gsim-account.component';
|
||||||
import { ManageSavingsAccountComponent } from './saving-account-actions/manage-savings-account/manage-savings-account.component';
|
import { ManageSavingsAccountComponent } from './saving-account-actions/manage-savings-account/manage-savings-account.component';
|
||||||
import { ReleaseAmountDialogComponent } from './savings-account-view/custom-dialogs/release-amount-dialog/release-amount-dialog.component';
|
import { ReleaseAmountDialogComponent } from './savings-account-view/custom-dialogs/release-amount-dialog/release-amount-dialog.component';
|
||||||
|
import { SavingsDocumentsTabComponent } from './savings-account-view/savings-documents-tab/savings-documents-tab.component';
|
||||||
|
import { NotesTabComponent } from './savings-account-view/notes-tab/notes-tab.component';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +106,9 @@ import { ReleaseAmountDialogComponent } from './savings-account-view/custom-dial
|
|||||||
GsimAccountComponent,
|
GsimAccountComponent,
|
||||||
CreateGsimAccountComponent,
|
CreateGsimAccountComponent,
|
||||||
ManageSavingsAccountComponent,
|
ManageSavingsAccountComponent,
|
||||||
ReleaseAmountDialogComponent
|
ReleaseAmountDialogComponent,
|
||||||
|
SavingsDocumentsTabComponent,
|
||||||
|
NotesTabComponent
|
||||||
],
|
],
|
||||||
providers: [ ]
|
providers: [ ]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -286,4 +286,61 @@ export class SavingsService {
|
|||||||
return this.http.post(`/savingsaccounts/gsim`, gsimData);
|
return this.http.post(`/savingsaccounts/gsim`, gsimData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param savingAccountId Savings Id
|
||||||
|
* @returns The notes for particular loan
|
||||||
|
*/
|
||||||
|
getSavingsNotes(savingAccountId: string): Observable<any> {
|
||||||
|
return this.http.get(`/savings/${savingAccountId}/notes`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a note to the particular Savings Id
|
||||||
|
* @param savingAccountId Savings ID
|
||||||
|
* @param noteData Note Data to be added
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
createSavingsNote(savingAccountId: string, noteData: any): Observable<any> {
|
||||||
|
return this.http.post(`/savings/${savingAccountId}/notes`, noteData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits the Savings Note
|
||||||
|
* @param savingAccountId Savings ID
|
||||||
|
* @param noteId Note ID
|
||||||
|
* @param noteData Note Data
|
||||||
|
*/
|
||||||
|
editSavingsNote(savingAccountId: string, noteId: string, noteData: any) {
|
||||||
|
return this.http.put(`/savings/${savingAccountId}/notes/${noteId}`, noteData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the particular Note
|
||||||
|
* @param savingAccountId Savings ID
|
||||||
|
* @param noteId Note ID
|
||||||
|
*/
|
||||||
|
deleteSavingsNote(savingAccountId: string, noteId: string) {
|
||||||
|
return this.http.delete(`/savings/${savingAccountId}/notes/${noteId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param savingAccountId Savings Account Id of account to get data for.
|
||||||
|
* @returns {Observable<any>} Savings data.
|
||||||
|
*/
|
||||||
|
getSavingsDocuments(savingAccountId: any): Observable<any> {
|
||||||
|
return this.http.get(`/savings/${savingAccountId}/documents`);
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadSavingsDocument(parentEntityId: string, documentId: string) {
|
||||||
|
return this.http.get(`/savings/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' });
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteSavingsDocument(savingAccountId: any, documentId: any): Observable<any> {
|
||||||
|
return this.http.delete(`/savings/${savingAccountId}/documents/${documentId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadSavingsDocument(savingAccountId: any, data: any): Observable<any> {
|
||||||
|
return this.http.post(`/savings/${savingAccountId}/documents`, data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import { MaterialModule } from './material.module';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ExternalIdentifierComponent } from './external-identifier/external-identifier.component';
|
import { ExternalIdentifierComponent } from './external-identifier/external-identifier.component';
|
||||||
import { PipesModule } from 'app/pipes/pipes.module';
|
import { PipesModule } from 'app/pipes/pipes.module';
|
||||||
|
import { EntityNotesTabComponent } from './tabs/entity-notes-tab/entity-notes-tab.component';
|
||||||
|
import { EntityDocumentsTabComponent } from './tabs/entity-documents-tab/entity-documents-tab.component';
|
||||||
|
import { DirectivesModule } from 'app/directives/directives.module';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared Module
|
* Shared Module
|
||||||
@@ -42,7 +45,8 @@ import { PipesModule } from 'app/pipes/pipes.module';
|
|||||||
MaterialModule,
|
MaterialModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
PipesModule
|
PipesModule,
|
||||||
|
DirectivesModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
FormfieldComponent,
|
FormfieldComponent,
|
||||||
@@ -63,7 +67,9 @@ import { PipesModule } from 'app/pipes/pipes.module';
|
|||||||
SearchToolComponent,
|
SearchToolComponent,
|
||||||
ServerSelectorComponent,
|
ServerSelectorComponent,
|
||||||
TenantSelectorComponent,
|
TenantSelectorComponent,
|
||||||
ExternalIdentifierComponent
|
ExternalIdentifierComponent,
|
||||||
|
EntityNotesTabComponent,
|
||||||
|
EntityDocumentsTabComponent
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
FileUploadComponent,
|
FileUploadComponent,
|
||||||
@@ -81,7 +87,9 @@ import { PipesModule } from 'app/pipes/pipes.module';
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
TenantSelectorComponent,
|
TenantSelectorComponent,
|
||||||
ExternalIdentifierComponent
|
ExternalIdentifierComponent,
|
||||||
|
EntityNotesTabComponent,
|
||||||
|
EntityDocumentsTabComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SharedModule { }
|
export class SharedModule { }
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<div class="tab-container mat-typography">
|
||||||
|
<div fxLayout="row" fxLayoutAlign="start center">
|
||||||
|
|
||||||
|
<h3 fxFlex="90%">Documents</h3>
|
||||||
|
|
||||||
|
<div fxFlex="10%" *mifosxHasPermission="'CREATE_DOCUMENT'">
|
||||||
|
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()">
|
||||||
|
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table mat-table #documentsTable [dataSource]="dataSource" matSort>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="name">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||||
|
<td mat-cell *matCellDef="let document"> {{ document.name }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="description">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Description </th>
|
||||||
|
<td mat-cell *matCellDef="let document"> {{ document.description }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="filename">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> File Name </th>
|
||||||
|
<td mat-cell *matCellDef="let document"> {{ document.fileName }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="actions">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Actions </th>
|
||||||
|
<td mat-cell *matCellDef="let document; let index">
|
||||||
|
<button class="document-action-button" mat-raised-button color="primary"
|
||||||
|
(click)="downloadDocument(document.id)">
|
||||||
|
<fa-icon icon="cloud-download-alt"></fa-icon>
|
||||||
|
</button>
|
||||||
|
<button class="document-action-button" mat-raised-button color="warn"
|
||||||
|
(click)="deleteDocument(document.id, document.name)">
|
||||||
|
<fa-icon icon="times"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<mat-paginator *ngIf="entityDocuments.length > 10" [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 3%;
|
||||||
|
.document-action-button {
|
||||||
|
min-width: 26px;
|
||||||
|
padding: 0 6px;
|
||||||
|
margin: 4px;
|
||||||
|
line-height: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-container {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EntityDocumentsTabComponent } from './entity-documents-tab.component';
|
||||||
|
|
||||||
|
describe('EntityDocumentsTabComponent', () => {
|
||||||
|
let component: EntityDocumentsTabComponent;
|
||||||
|
let fixture: ComponentFixture<EntityDocumentsTabComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ EntityDocumentsTabComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EntityDocumentsTabComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
|
import { MatSort } from '@angular/material/sort';
|
||||||
|
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-dialogs/upload-document-dialog/upload-document-dialog.component';
|
||||||
|
import { ClientsService } from 'app/clients/clients.service';
|
||||||
|
import { LoansService } from 'app/loans/loans.service';
|
||||||
|
import { SavingsService } from 'app/savings/savings.service';
|
||||||
|
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-entity-documents-tab',
|
||||||
|
templateUrl: './entity-documents-tab.component.html',
|
||||||
|
styleUrls: ['./entity-documents-tab.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityDocumentsTabComponent implements OnInit {
|
||||||
|
@ViewChild('documentsTable', { static: true }) documentsTable: MatTable<Element>;
|
||||||
|
|
||||||
|
@Input() entityId: string;
|
||||||
|
@Input() entityType: string;
|
||||||
|
@Input() entityDocuments: any;
|
||||||
|
|
||||||
|
@Input() callbackUpload: (documentData: FormData) => Observable<any>;
|
||||||
|
@Input() callbackDownload: (documentId: string) => void;
|
||||||
|
@Input() callbackDelete: (documentId: string) => void;
|
||||||
|
|
||||||
|
/** Status of the loan account */
|
||||||
|
status: any;
|
||||||
|
/** Choice */
|
||||||
|
choice: boolean;
|
||||||
|
|
||||||
|
/** Columns to be displayed in loan documents table. */
|
||||||
|
displayedColumns: string[] = ['name', 'description', 'filename', 'actions'];
|
||||||
|
/** Data source for loan documents table. */
|
||||||
|
dataSource: MatTableDataSource<any>;
|
||||||
|
|
||||||
|
/** Paginator for codes table. */
|
||||||
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
/** Sorter for codes table. */
|
||||||
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {MatDialog} dialog Dialog for Inputs.
|
||||||
|
* @param {SavingsService} savingsService Savings Account services.
|
||||||
|
* @param {LoansService} loansService Loan Account services.
|
||||||
|
* @param {ClientsService} clientsService Client services.
|
||||||
|
*/
|
||||||
|
constructor(public dialog: MatDialog,
|
||||||
|
private savingsService: SavingsService,
|
||||||
|
private loansService: LoansService,
|
||||||
|
private clientsService: ClientsService) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.dataSource = new MatTableDataSource(this.entityDocuments);
|
||||||
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadDocument(documentId: string) {
|
||||||
|
this.callbackDownload(documentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadDocument() {
|
||||||
|
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
|
||||||
|
data: { documentIdentifier: false, entityType: 'Loan' }
|
||||||
|
});
|
||||||
|
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
||||||
|
if (dialogResponse) {
|
||||||
|
const formData: FormData = new FormData;
|
||||||
|
formData.append('name', dialogResponse.fileName);
|
||||||
|
formData.append('file', dialogResponse.file);
|
||||||
|
formData.append('description', dialogResponse.description);
|
||||||
|
this.callbackUpload(formData).subscribe((res: any) => {
|
||||||
|
this.entityDocuments.push({
|
||||||
|
id: res.resourceId,
|
||||||
|
parentEntityType: this.entityType,
|
||||||
|
parentEntityId: this.entityId,
|
||||||
|
name: dialogResponse.fileName,
|
||||||
|
description: dialogResponse.description,
|
||||||
|
fileName: dialogResponse.file.name
|
||||||
|
});
|
||||||
|
this.documentsTable.renderRows();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteDocument(documentId: string, name: number) {
|
||||||
|
const deleteDocumentDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
|
data: { deleteContext: `Document: ${name}` }
|
||||||
|
});
|
||||||
|
deleteDocumentDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.delete) {
|
||||||
|
this.callbackDelete(documentId);
|
||||||
|
for (let i = 0; i < this.entityDocuments.length; i++) {
|
||||||
|
if (this.entityDocuments[i].id === documentId) {
|
||||||
|
this.entityDocuments.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.documentsTable.renderRows();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<div class="tab-container mat-typography">
|
||||||
|
|
||||||
|
<h3>Notes</h3>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
||||||
|
(ngSubmit)="addNote()">
|
||||||
|
<mat-form-field fxFlex="calc(90%-20px)">
|
||||||
|
<textarea required formControlName="note" matInput placeholder="Write a note ...." cdkTextareaAutosize cdkAutosizeMinRows="2"></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid">
|
||||||
|
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-list>
|
||||||
|
<mat-list-item *ngFor="let entityNote of entityNotes; let i=index;">
|
||||||
|
<fa-icon icon="sticky-note" matListIcon></fa-icon>
|
||||||
|
<h3 matLine>{{ entityNote.note }} </h3>
|
||||||
|
<p matLine>
|
||||||
|
<span>Created by: {{entityNote.createdByUsername}}</span><br />
|
||||||
|
<span>Date: {{entityNote.createdOn | dateFormat}}</span>
|
||||||
|
</p>
|
||||||
|
<div fxLayout="row" fxLayoutAlign="flex-start">
|
||||||
|
<button mat-button color="primary" (click)="editNote(entityNote.id, entityNote.note, i)">
|
||||||
|
<fa-icon icon="edit"></fa-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-button color="warn" (click)="deleteNote(entityNote.id, i)">
|
||||||
|
<fa-icon icon="trash"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</mat-list-item>
|
||||||
|
</mat-list>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
.tab-container {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EntityNotesTabComponent } from './entity-notes-tab.component';
|
||||||
|
|
||||||
|
describe('EntityNotesTabComponent', () => {
|
||||||
|
let component: EntityNotesTabComponent;
|
||||||
|
let fixture: ComponentFixture<EntityNotesTabComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ EntityNotesTabComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EntityNotesTabComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ClientsService } from 'app/clients/clients.service';
|
||||||
|
import { LoansService } from 'app/loans/loans.service';
|
||||||
|
import { SavingsService } from 'app/savings/savings.service';
|
||||||
|
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||||
|
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-entity-notes-tab',
|
||||||
|
templateUrl: './entity-notes-tab.component.html',
|
||||||
|
styleUrls: ['./entity-notes-tab.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityNotesTabComponent implements OnInit {
|
||||||
|
|
||||||
|
@ViewChild('formRef', { static: true }) formRef: any;
|
||||||
|
|
||||||
|
@Input() entityId: string;
|
||||||
|
@Input() entityNotes: any;
|
||||||
|
|
||||||
|
@Input() callbackAdd: (note: any) => void;
|
||||||
|
@Input() callbackEdit: (noteId: string, note: string, index: number) => void;
|
||||||
|
@Input() callbackDelete: (noteId: string, index: number) => void;
|
||||||
|
|
||||||
|
noteForm: FormGroup;
|
||||||
|
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private savingsService: SavingsService,
|
||||||
|
private loansService: LoansService,
|
||||||
|
private clientsService: ClientsService,
|
||||||
|
private dialog: MatDialog) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.createNoteForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
createNoteForm() {
|
||||||
|
this.noteForm = this.formBuilder.group({
|
||||||
|
'note': ['', Validators.required]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addNote() {
|
||||||
|
this.callbackAdd(this.noteForm.value);
|
||||||
|
this.formRef.resetForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
editNote(noteId: string, noteContent: string, index: number) {
|
||||||
|
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
|
||||||
|
data: { formfields: [{
|
||||||
|
controlName: 'note',
|
||||||
|
required: true,
|
||||||
|
value: noteContent,
|
||||||
|
controlType: 'input',
|
||||||
|
label: 'Note'
|
||||||
|
}],
|
||||||
|
layout: {
|
||||||
|
columns: 1,
|
||||||
|
addButtonText: 'Confirm'
|
||||||
|
},
|
||||||
|
title: 'Edit Note'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
editNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.data && response.data.value.note !== noteContent) {
|
||||||
|
this.callbackEdit(noteId, response.data.value, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteNote(noteId: string, index: number) {
|
||||||
|
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
|
data: { deleteContext: `Note: ${this.entityNotes[index].note}` }
|
||||||
|
});
|
||||||
|
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.delete) {
|
||||||
|
this.callbackDelete(noteId, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,4 +14,6 @@
|
|||||||
// Language Environment variables
|
// Language Environment variables
|
||||||
window["env"]["defaultLanguage"] = '';
|
window["env"]["defaultLanguage"] = '';
|
||||||
window["env"]["supportedLanguages"] = '';
|
window["env"]["supportedLanguages"] = '';
|
||||||
|
|
||||||
|
window['env']['preloadClients'] = '';
|
||||||
})(this);
|
})(this);
|
||||||
|
|||||||
@@ -14,4 +14,6 @@
|
|||||||
// Language Environment variables
|
// Language Environment variables
|
||||||
window["env"]["defaultLanguage"] = '$MIFOS_DEFAULT_LANGUAGE';
|
window["env"]["defaultLanguage"] = '$MIFOS_DEFAULT_LANGUAGE';
|
||||||
window["env"]["supportedLanguages"] = '$MIFOS_SUPPORTED_LANGUAGES';
|
window["env"]["supportedLanguages"] = '$MIFOS_SUPPORTED_LANGUAGES';
|
||||||
|
|
||||||
|
window['env']['preloadClients'] = '$MIFOS_PRELOAD_CLIENTS';
|
||||||
})(this);
|
})(this);
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ export const environment = {
|
|||||||
serverUrl: ''
|
serverUrl: ''
|
||||||
},
|
},
|
||||||
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
|
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
|
||||||
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR'
|
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR',
|
||||||
|
preloadClients: window['env']['preloadClients'] || true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Server URL
|
// Server URL
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export const environment = {
|
|||||||
serverUrl: ''
|
serverUrl: ''
|
||||||
},
|
},
|
||||||
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
|
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
|
||||||
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR'
|
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR',
|
||||||
|
preloadClients: window['env']['preloadClients'] || true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Server URL
|
// Server URL
|
||||||
|
|||||||
Reference in New Issue
Block a user