Fairoj : SMC MIS report

This commit is contained in:
venbatechnologies@gmail.com 2021-03-15 13:02:44 +05:30
parent f80a6e0e0e
commit 0f9d677c28
11 changed files with 605 additions and 6 deletions

View File

@ -1,11 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PdMisComponent } from './pd-mis/pd-mis.component';
import { SmcCreditComponent } from './smc-credit/smc-credit.component';
const routes: Routes = [
{
path:'',
component:PdMisComponent
},
{
path:'SMC-MIS',
component:SmcCreditComponent
}
];

View File

@ -27,6 +27,7 @@ import { ReportsRoutingModule } from './reports-routing.module';
import { PdMisComponent } from './pd-mis/pd-mis.component';
import {NotifierModule,NotifierOptions} from 'angular-notifier'
import { MatTableExporterModule } from 'mat-table-exporter';
import { SmcCreditComponent } from './smc-credit/smc-credit.component';
const pdCustomNotifierOptions: NotifierOptions = {
@ -97,7 +98,7 @@ const pdCustomNotifierOptions: NotifierOptions = {
MatTableExporterModule
],
exports: [MatExpansionModule],
declarations: [PdMisComponent],
declarations: [PdMisComponent, SmcCreditComponent],
providers:[ReportsService,{provide: MAT_DATE_LOCALE, useValue: 'en-GB'},{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},]
})

View File

@ -28,4 +28,7 @@ export class ReportsService {
pdTATReport(value):Observable<any>{
return this._http.post(this.apiUrl + 'pdTATReport',value);
}
smcCreditPDMisReport(params):Observable<any> {
return this._http.post(this.apiUrl+'smcCreditPDMisReport',params)
}
}

View File

@ -0,0 +1,190 @@
<!-- <div *ngIf="listView"> -->
<mat-card>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-1">
<div class="ml-xs mr-xs" style="width: 100%;">
<mat-card-title><span>SMC Credit PD MIS Report </span>
<button class="btn_export" mat-raised-button color="primary" (click)="exp.exportTable('xlsx',{fileName:'SMC Credit PD MIS Report'})" [disabled]="dataLength == 0 ? true : false || dataLength == -1 ? true : false" >Excel Export</button>
<!-- (click)="ExportTOExcel()" -->
</mat-card-title>
</div>
</div>
<mat-card-content no-padding #card_c>
<div *ngIf="!Loading" class="report-card-container mat-elevation-z8">
<div class="relative" *ngIf="error.length > 0;else anotherdata;">
<div class="form-back">
<div class="relative error-wrapper" *ngFor="let er of error let i = index;">
<mat-icon class="error-icon" style="color:red;">error</mat-icon>
<h1 style="color:red;"> Error! </h1>
<span *ngIf="er.error_type == 2" class="error-text" style="color:red;">{{er.error_status}}</span>
<h2 style="color:red;"> {{er.error_text}} </h2>
<div class="error-details" style="color:red;">
<p>Sorry, but the page you were trying to view does not exist</p>
<p *ngIf="er.error_type == 2" >{{er.error_message}}</p>
</div>
</div>
</div>
</div>
<ng-template #anotherdata>
<br/>
<div fxLayout="row" fxLayoutAlign="start center" class="filter-header">
<div class="ml-xs mr-xs" style="width: 100%;">
<form [formGroup]="reportform">
<mat-expansion-panel [(expanded)]="expandStatus">
<mat-expansion-panel-header>
<mat-panel-title class="text-xs-left">
<h6 class="mt-0">
<mat-icon>filter_list</mat-icon> Filter</h6>
</mat-panel-title>
</mat-expansion-panel-header>
<div>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<input matInput type="text" placeholder="Officer Name" formControlName="officer_name">
</mat-form-field>
<mat-form-field class="ml-xs mr-xs" style="width:30%">
<input matInput [max]="maxDate" [matDatepicker]="picker" formControlName="from_date" placeholder="From Date" (dateChange)="getDateObjects($event.target.value)">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker touchUi #picker></mat-datepicker>
</mat-form-field>
<mat-form-field class="ml-xs mr-xs" style="width:30%">
<input matInput [matDatepicker]="picker1" [min]="minDate" [max]="maxDate" formControlName="to_date" placeholder="To Date">
<mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker touchUi #picker1 ></mat-datepicker>
</mat-form-field>
<!-- <mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<input matInput type="text" placeholder="Lender Short Name" formControlName="lender_id">
</mat-form-field> -->
<div align="right">
<button type="button" mat-raised-button mat-icon-button (click)="onReset()"
matTooltip="Reset" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary">
<mat-icon>settings_backup_restore</mat-icon>
</button>
<button type="button" mat-raised-button mat-icon-button
matTooltip="Search" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" type="button" (click)="searchPanel()">
<mat-icon>search</mat-icon>
</button>
</div>
</div>
</mat-expansion-panel>
</form>
<br/>
</div>
</div>
<div class="report-table-container mat-elevation-z8 " #TABLE>
<div *ngIf="dataLength != 0 && dataLength != -1" #table_start>
<table mat-table matTableExporter [dataSource]="dataSource" matSort #exporter="matTableExporter">
<ng-container matColumnDef="serialno">
<th mat-header-cell *matHeaderCellDef mat-sort-header >Sr. No. </th>
<td mat-cell *matCellDef="let row; let i = index;"> {{i+1}} </td>
</ng-container>
<!-- <ng-container matColumnDef="credit_pd_id" >
<th mat-header-cell *matHeaderCellDef mat-sort-header>Sales PD ID</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.credit_pd_id" mat-line>{{row.creditpd_id}}</span> </td>
</ng-container> -->
<ng-container matColumnDef="credit_pd_sno">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Reference Number</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.pd_sno" mat-line>{{row.pd_sno}}</span> </td>
</ng-container>
<ng-container matColumnDef="applicant_name" sticky>
<th mat-header-cell *matHeaderCellDef mat-sort-header>Main Loan Applicant </th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.applicant_name" mat-line>{{row.applicant_name}}</span> </td>
</ng-container>
<ng-container matColumnDef="credit_pd_type" sticky>
<th mat-header-cell *matHeaderCellDef mat-sort-header>Credit PD Type</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.type_name" mat-line>{{row.type_name}}</span>
<!-- <span *ngIf="row.sales_pd_type == 1" mat-line>Physical PD</span> </td> -->
</ng-container>
<ng-container matColumnDef="product_abbr">
<th mat-header-cell *matHeaderCellDef >Product Type</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.abbr" mat-line>{{row.abbr}}</span>
</ng-container>
<ng-container matColumnDef="officer_name">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Credit Person</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.officer_name" mat-line>{{row.officer_name}}</span> </td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Status</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.pd_status" mat-line>{{row.pd_status}}</span> </td>
</ng-container>
<ng-container matColumnDef="createdon">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Date</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.updatedon" mat-line> {{row.updatedon | date: 'dd-MM-yyyy hh:mm a'}}</span> </td>
</ng-container>
<!-- <ng-container matColumnDef="mail_status">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Mail Status</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.mail_status" mat-line> {{row.mail_status}}</span> </td>
</ng-container> -->
<!-- <ng-container matColumnDef="applicant_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Applicant ID</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.applicant_id" mat-line>{{row.applicant_id}}</span> </td>
</ng-container>
<ng-container matColumnDef="abbr">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Product</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.abbr" mat-line>{{row.abbr}}</span> </td>
</ng-container> -->
<!-- <ng-container matColumnDef="short_name">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Lender</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.short_name" mat-line>{{row.short_name}}</span> </td>
</ng-container> -->
<tr mat-header-row *matHeaderRowDef="displayedColumns" ></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;">
</tr>
</table>
</div>
<div *ngIf="dataLength == 0" class="nocontent ml-xs mr-xs" style="padding: 1rem !important;">No records found</div>
</div>
</ng-template>
</div>
<div *ngIf="Loading">
<div fxLayoutAlign="center">
<mat-progress-spinner mode="indeterminate" class="primary"></mat-progress-spinner>
</div>
<p class="nocontent">Fetching Report...</p>
</div>
</mat-card-content>
</mat-card>
<!-- </div> -->
<!-- <div *ngIf="!listView">
<app-pd-team-edit [childMessage]="parentMessage"></app-pd-team-edit>
</div> -->

View File

@ -0,0 +1,99 @@
/** Card title */
.mat-card-title{
font-size: 25px !important;
}
/** CSS for "No record Found Text " and "Loading Text" */
.nocontent {
color: red;
font-size: 16px;
text-align: center;
width: 100%;
}
/** Filter Header Css (Overall) */
.filter-header {
min-height: 64px;
padding: 8px 24px 0;
}
/** Export Button CSS */
.btn_export
{
float: right;
}
/** Report Card Common Css (Overall) */
.report-card-container {
display: flex;
flex-direction: column;
min-width: 300px;
}
/** Report Table Common Css (Overall)*/
.report-table-container {
max-height:540px;
width: auto;
overflow: auto;
margin-top: 2%;
}
/** Table Header Cell Css*/
.mat-header-cell {
padding: 0 10px 0 10px;
white-space: pre-wrap;
font-size: 1rem !important;
}
/** Table Body Cell Css*/
.mat-cell {
padding: 0 10px 0 10px;
white-space: nowrap;
}
/** Table Static Columns Css*/
.mat-table-sticky {
border-right: 1px solid #e0e0e0;
}
/** Table Footer Cell Css - not In use*/
.mat-footer-cell {
font-weight: bold;
font-size: 1.2rem !important;
padding: 0 10px 0 10px;
}
/* Error Text Font Size*/
.error-text{
font-size: 6rem !important;
}
.error-wrapper{
padding-top: 2rem !important;//default is 5 rem
}
.error-icon{
width: 100px;
font-size: 79px !important;
}
.form-back{
background-position: top center;
min-height: calc(100vh + 100px);
height: auto;
background-color: #fff !important;
color:red !important;
}
.mat-column-status{
text-align: center;
}
.mat-column-serialno{
text-align: center;
}
.mat-column-credit_pd_id{
text-align: center;
}
.mat-column-createdon{
text-align: center;
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SmcCreditComponent } from './smc-credit.component';
describe('SmcCreditComponent', () => {
let component: SmcCreditComponent;
let fixture: ComponentFixture<SmcCreditComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SmcCreditComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SmcCreditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,274 @@
import { DatePipe } from '@angular/common';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { PageEvent, MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
import { Router } from '@angular/router';
import { NotifierService } from 'angular-notifier';
import { SalesPdService } from 'app/sales-pd/services/sales-pd.service';
import { ReportsService } from '../reports.service';
@Component({
selector: 'app-smc-credit',
templateUrl: './smc-credit.component.html',
styleUrls: ['./smc-credit.component.scss']
})
export class SmcCreditComponent implements OnInit {
@ViewChild('card_c') scroll_table:ElementRef
pageEvent:PageEvent;
pipe = new DatePipe('en-US');
maxDate: any;
minDate: any;
api_data:any=[];
filtered_data:any=[];
public Loading: boolean;
public reportform: FormGroup;
public dataLength:number=-1;
public pageSize : number;
public dataSource = new MatTableDataSource();
error:any=[];
pageNumber:number=10;
pageIndex:number=0
displayedColumns = ['serialno',
// 'credit_pd_id',
'credit_pd_sno',
'applicant_name',
'credit_pd_type',
'product_abbr',
'officer_name',
'status',
'createdon',
// 'mail_status'
];
expandStatus: boolean=true;
constructor(private reportService:ReportsService,private router:Router,private form_builder:FormBuilder,private notifier:NotifierService) {
this.reportform = this.form_builder.group({
from_date:[null],to_date:[null],officer_name:[null],lender_id:[null]});
}
ngOnInit(){
this.maxDate = new Date();
// this.getMISDailyReport();
}
getMISDailyReport() {
let array=[]
this.reportService.smcCreditPDMisReport(array).subscribe(
data => {
if(data.dataStatus == true){
this.api_data = data.records;
this.dataLength = data.records.length;
this.pageSize = data.records.length;
// if(data.records.length >= 1){
// this.api_data = this.api_data.map((val, i)=>{
// val['serialno'] = i + 1;
// return val;
// })
// }
this.dataSource.data = this.api_data;
this.Loading = false;
}else{
this.dataLength = 0;
// this.Loading = true;
}
},
error => {
this.error.push(error);
this.dataLength = 0;
this.Loading = false;
})
}
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
// @ViewChild('TABLE') table: ElementRef;
@ViewChild('TABLE',{ read: ElementRef }) table: ElementRef;
@ViewChild('exporter') exp
// exportAsExcel():void {
// const ws: XLSX.WorkSheet=XLSX.utils.table_to_sheet(this.table.nativeElement);
// const wb: XLSX.WorkBook = XLSX.utils.book_new();
// XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// /* save to file */
// XLSX.writeFile(wb, 'Daily MIS Report.xlsx');
// }
// exportAsCSV(){
// console.log(this.exp)
// var options = {
// fieldSeparator: ',',
// quoteStrings: '"',
// decimalseparator: '.',
// showLabels: true,
// showTitle: true,
// title: 'Your title',
// useBom: true,
// noDownload: true,
// headers: this.displayedColumns,
// nullToEmptyString: true,
// };
// // console.log(this.table.nativeElement)
// new AngularCsv(this.dataSource.data,'sample')
// }
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
/** For Display Tables Filtering */
applyFilter(filterValue: string) {
filterValue = filterValue.trim(); // Remove whitespace
filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches
this.dataSource.filter = filterValue;
}
pageChange(e) {
console.log(e);
}
searchPanel(){
this.Loading=true;
this.reportform.value.from_date=this.pipe.transform(this.reportform.value.from_date,'yyyy-MM-dd')
this.reportform.value.to_date=this.pipe.transform(this.reportform.value.to_date,'yyyy-MM-dd')
// OLD API
// this.reportsService.retirveDataForMISDailyReport(this.reportform.value).subscribe(res=>{
this.reportService.smcCreditPDMisReport(this.reportform.value).subscribe(res=>{
if(res['dataStatus'] == true){
this.dataSource.data=res['records'];
this.dataLength=res['records'].length;
setTimeout(()=>{
console.log(this.exp);
})
this.expandStatus=false
// const element = document.querySelector('.report-card-container');
// this.scroll_table.nativeElement.scrollIntoView(true)
setTimeout(()=>{
this.scroll_table.nativeElement.scrollIntoView({block:"end"})
console.log("Console",this.scroll_table,this.table,this.exp)
})
if(this.dataLength == 0){
console.log("data length",this.dataLength)
this.notifier.notify('warning', 'No Records Found !');
this.dataSource.data = [];
this.dataLength=0
}
}
else{
this.notifier.notify('Warning', 'Something Went Wrong');
this.dataSource.data = [];
this.dataLength=0
}
this.Loading=false
},error => {
//this.errorMessage.push(error);
this.error.push(error)
this.dataLength=0
this.Loading = false;
this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
alert(error.html_format);
});
}
onReset(){
// if(this.reportform.value.filter(val=>val.))
// this.Loading=true
this.reportform.reset();
this.dataLength = -1;
// this.getMISDailyReport()
// this.expandStatus=false
}
filterForApplicantID(arrayData: any, Values: any) {
Values = Values.toLowerCase();
if (Values) {
let Filter: any = [];
let getAllApplicationIDOnly = arrayData.map(v => v.application_id.replace(/[^A-Za-z0-9]/ig, "").toLowerCase());
let searched_filter_array = getAllApplicationIDOnly.filter(val => val.includes(Values));
Filter = searched_filter_array.map(x => {
let findIndex = getAllApplicationIDOnly.indexOf(x);
return arrayData[findIndex];
});
return Filter.length > 0 ? Filter : arrayData;
}
else{
return arrayData;
}
}
filterForCity(arrayData: any, Values: any) {
Values = Values.toLowerCase();
if (Values) {
let Filter: any = [];
// console.log("arra",JSON.parse(arrayData),Values);
let getAllCityOnly = arrayData.map(v => v.city.replace(/[^A-Za-z0-9]/ig, "").toLowerCase());
console.log("getall ",getAllCityOnly)
let searched_filter_array = getAllCityOnly.filter(val => val.includes(Values));
Filter = searched_filter_array.map(x => {
console.log("x",x);
let findIndex = getAllCityOnly.indexOf(x);
return arrayData[findIndex];
});
return Filter.length > 0 ? Filter : arrayData;
}
else{
return arrayData;
}
}
filterForBranch(arrayData: any, Values: any) {
Values = Values.toLowerCase();
if (Values) {
let Filter: any = [];
let getAllBranchOnly = arrayData.map(v => v.branch.replace(/[^A-Za-z0-9]/ig, "").toLowerCase());
let searched_filter_array = getAllBranchOnly.filter(val => val.includes(Values));
Filter = searched_filter_array.map(x => {
let findIndex = getAllBranchOnly.indexOf(x);
return arrayData[findIndex];
});
return Filter.length > 0 ? Filter : arrayData;
}
else{
return arrayData;
}
}
// customFilter(array,value,flag){
// if(flag == 3){
// var str = array.branch.split("").join("").toLowercase();
// return str.includes(value)?array:null;
// }
// }
getDateObjects(values: any) {
let selected_date = this.pipe.transform(values, 'yyyy/MM/dd');
this.minDate = new Date(selected_date);
}
}

View File

@ -91,11 +91,11 @@
<td mat-cell *matCellDef="let row; let i = index;"> {{i+1}} </td>
</ng-container>
<ng-container matColumnDef="sales_pd_id" >
<!-- <ng-container matColumnDef="sales_pd_id" >
<th mat-header-cell *matHeaderCellDef mat-sort-header>Sales PD ID</th>
<td mat-cell *matCellDef="let row">
<span *ngIf="row.sales_pd_id" mat-line>{{row.sales_pd_id}}</span> </td>
</ng-container>
</ng-container> -->
<ng-container matColumnDef="sales_pd_sno">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Reference Number</th>

View File

@ -36,7 +36,7 @@ export class MisReportsComponent implements OnInit {
pageIndex:number=0
displayedColumns = ['serialno',
'sales_pd_id',
// 'sales_pd_id',
'sales_pd_sno',
'applicant_name',
'sales_pd_type',

View File

@ -35,7 +35,8 @@ const HORIZONTALMENUITEMS = [
icon:'report',
children:[
{state:'reports',name:'Credit PD'},
{state:'sales-pd-list/reports',name:'Sales PD'}
{state:'sales-pd-list/reports',name:'Sales PD'},
{state:'reports/SMC-MIS',name:'SMC Credit PD'}
]
},
{

View File

@ -119,7 +119,8 @@ const MENUITEMS : Menu[] = [
icon:'report',
children:[
{state:'reports',name:'Credit PD'},
{state:'sales-pd-list/reports',name:'Sales PD'}
{state:'sales-pd-list/reports',name:'Sales PD'},
{state:'reports/SMC-MIS',name:'SMC Credit PD'}
]
}
];