cfpl loan form

This commit is contained in:
gayathri1990 2021-03-10 13:18:25 +05:30
parent b7636c034d
commit 6407ffd8a9
4 changed files with 197 additions and 7 deletions

View File

@ -12,7 +12,7 @@
</div>
</h2>
<mat-dialog-content style="border-bottom: 2px solid #e2412f8f;">
<mat-tab-group>
<mat-tab-group>
<mat-tab label="Details">
<ng-template matTabContent>
<div fxLayout="row wrap">

View File

@ -12,7 +12,7 @@ import {
FormArray, FormControl, AbstractControl,
} from '@angular/forms';
import { NotifierService } from 'angular-notifier';
import { NotifierService } from 'angular-notifier';
import {
MatDialog,

View File

@ -13,7 +13,7 @@
</h2>
<mat-dialog-content style="border-bottom: 2px solid #e2412f8f;">
<mat-tab-group>
<mat-tab label="Details">
<ng-template matTabContent>
@ -316,6 +316,126 @@
</mat-card-content>
</mat-card>
</mat-card>
<mat-card *ngIf="lenderShortName == 'CFPL'">
<mat-card-header>
<mat-card-title>Anchor Details Section</mat-card-title>
</mat-card-header>
<mat-card-content class="matcard">
<mat-form-field style="width: 64%">
<input matInput placeholder="Facility Amount Applied For? " formControlName="facility_amount"
OnlyNumber type="text" (change)="loanCalc()"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['facility_amount'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['facility_amount'].value | numberToWords }} Only</mat-hint>
<!-- <mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['loan_amount'].value != ''">{{"&#8377;"}}
{{loanAmtInWords}} Only</mat-hint> -->
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Name of the Anchor"
type="text" formControlName="anchor_name"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['anchor_name'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['anchor_name'].value }}</mat-hint>
</mat-form-field>
<h6>Applicant's association vintage with the Anchor</h6>
<mat-form-field >
<input matInput placeholder="Year" formControlName="vintage_anchor_year"
OnlyNumber type="text" required>
</mat-form-field>
<mat-form-field >
<input matInput placeholder="Month" formControlName="vintage_anchor_month"
OnlyNumber type="text" >
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Monthly business (sale/purchase) with the Anchor" formControlName="monthly_business_anchor"
OnlyNumber type="text" (change)="loanCalc()"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['monthly_business_anchor'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['monthly_business_anchor'].value | numberToWords }} Only</mat-hint>
<!-- <mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['loan_amount'].value != ''">{{"&#8377;"}}
{{loanAmtInWords}} Only</mat-hint> -->
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Business concentration with Anchor" formControlName="business_concentration"
OnlyNumber type="text" (change)="loanCalc()"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['business_concentration'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['business_concentration'].value | numberToWords }} Only</mat-hint>
<!-- <mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['loan_amount'].value != ''">{{"&#8377;"}}
{{loanAmtInWords}} Only</mat-hint> -->
</mat-form-field>
<h6>Credit period with the Anchor (Days)</h6>
<mat-form-field style="width: 28%">
<input matInput placeholder="Days" formControlName="credit_period_days"
OnlyNumber type="text" >
</mat-form-field>
<div>
<mat-form-field style="width: 64%">
<mat-select placeholder="Payment Mechanism" (selectionChange)="selectedBalancesTransferChanges($event.value)"
formControlName="payment_mechanism">
<mat-option>Select</mat-option>
<mat-option value="bill_wise">Bill-Wise</mat-option>
<mat-option value="open_account">Open Account</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Average Invoice Value" formControlName="average_invoicevalue"
OnlyNumber type="text" (change)="loanCalc()"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['average_invoicevalue'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['average_invoicevalue'].value | numberToWords }} Only</mat-hint>
<!-- <mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['loan_amount'].value != ''">{{"&#8377;"}}
{{loanAmtInWords}} Only</mat-hint> -->
</mat-form-field>
<span>
<mat-form-field style="width: 64%">
<input matInput placeholder="Are there peak seasons for the business with Anchor"
OnlyNumber type="text" formControlName="peakseasons_anchor"
(change)="loanCalc()" autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['peakseasons_anchor'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['peakseasons_anchor'].value | numberToWords }} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width: 64%">
<mat-select placeholder="Are there debit/credit notes being issued to/by Anchor" (selectionChange)="selectedBalancesTransferChanges($event.value)"
formControlName="anchor_notes">
<mat-option>Select</mat-option>
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Reason for such debit/credit notes"
type="text" formControlName="debitcredit_notes"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['balance_transfer_amount'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['balance_transfer_amount'].value | numberToWords }}</mat-hint>
</mat-form-field>
<mat-form-field style="width: 64%">
<input matInput placeholder="Value of stock related to Anchor" OnlyNumber type="text"
formControlName="stock_related_anchor"
autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="loanDetailsForm.controls['stock_related_anchor'].value != ''">{{"&#8377;"}} {{ loanDetailsForm.controls['stock_related_anchor'].value | numberToWords }} Only</mat-hint>
</mat-form-field>
<mat-form-field
style="width: 28%">
<input matInput placeholder="Observations on Sample Invoices"
formControlName="sample_invoices" autocomplete="off">
<mat-error *ngIf="loanDetailsForm.controls['sample_invoices'].hasError('required')">End Use of Top Up Required</mat-error>
</mat-form-field>
</span>
</div>
</mat-card-content>
</mat-card>
</div>
</div>
</ng-template>

View File

@ -2,7 +2,7 @@ import {
Component,
OnInit,
Inject,
Input
Input
} from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormArray, FormControl } from '@angular/forms';
@ -127,7 +127,7 @@ export class LoanDetailsComponent implements OnInit {
this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr;
this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr;
this.lenderShortName = this.pd_all_details.pdmaster_details.lender_short_name;
if (this.prod_catagory == 'PL' || this.prod_catagory == 'BL' || this.prod_catagory == 'LAP' || this.prod_catagory == 'LFMP') {
this.isContribution = true;
}
@ -145,6 +145,8 @@ export class LoanDetailsComponent implements OnInit {
/** init Fns */
ngOnInit() {
this.initloanDetailsForm();
console.log(this.loanDetailsForm.controls);
console.log('maran');
this.getM_EndUseofLoad();
this.getM_EndUseForLoan(this.pdid,this.pd_all_details.pdmaster_details.fk_subproduct_id);
this.getM_State();
@ -200,6 +202,27 @@ export class LoanDetailsComponent implements OnInit {
params.pd_id = this.pdid;
params.pd_form_id = this.form_id;
this._pd.retriveForm(params).subscribe(value => {
console.log(value);
console.log('fetching');
console.log(this.lenderShortName);
if(this.lenderShortName=='CFPL')
{
this.loanDetailsForm.controls['facility_amount'].setValue(value.records.facility_amount);
this.loanDetailsForm.controls['anchor_name'].setValue(value.records.anchor_name);
this.loanDetailsForm.controls['vintage_anchor_year'].setValue(value.records.vintage_anchor_year);
this.loanDetailsForm.controls['vintage_anchor_month'].setValue(value.records.vintage_anchor_month);
this.loanDetailsForm.controls['monthly_business_anchor'].setValue(value.records.monthly_business_anchor);
this.loanDetailsForm.controls['business_concentration'].setValue(value.records.business_concentration);
this.loanDetailsForm.controls['credit_period_days'].setValue(value.records.credit_period_days);
this.loanDetailsForm.controls['payment_mechanism'].setValue(value.records.payment_mechanism);
this.loanDetailsForm.controls['average_invoicevalue'].setValue(value.records.average_invoicevalue);
this.loanDetailsForm.controls['peakseasons_anchor'].setValue(value.records.peakseasons_anchor);
this.loanDetailsForm.controls['anchor_notes'].setValue(value.records.anchor_notes);
this.loanDetailsForm.controls['debitcredit_notes'].setValue(value.records.debitcredit_notes);
this.loanDetailsForm.controls['stock_related_anchor'].setValue(value.records.stock_related_anchor);
this.loanDetailsForm.controls['sample_invoices'].setValue(value.records.sample_invoices);
}
// *ngIf="prod_catagory === 'HL' || prod_catagory === 'LL' || prod_catagory === 'LAP' "
if (value.status == 200) {
let result = Object.keys(value.records.end_use_group).map(function (key) {
@ -499,7 +522,26 @@ export class LoanDetailsComponent implements OnInit {
pinSearch: [''],
other_pincode:[''],
loandetails_remarks: [''],
});
if(this.lenderShortName=='CFPL')
{
this.loanDetailsForm.addControl('facility_amount', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('anchor_name', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('vintage_anchor_year', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('vintage_anchor_month', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('monthly_business_anchor', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('business_concentration', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('credit_period_days', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('payment_mechanism', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('average_invoicevalue', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('peakseasons_anchor', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('anchor_notes', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('debitcredit_notes', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('stock_related_anchor', new FormControl('', Validators.required));
this.loanDetailsForm.addControl('sample_invoices', new FormControl('', Validators.required));
}
}
@ -772,7 +814,9 @@ export class LoanDetailsComponent implements OnInit {
/** To save Loan FOrm Details */
submitLoanDetails() {
alert('save');
alert(this.lenderShortName);
if(this.isOtherSource == false){
this.loanDetailsForm.controls['other_source'].setValue('');
this.loanDetailsForm.controls['other_source'].clearValidators();
@ -876,6 +920,7 @@ export class LoanDetailsComponent implements OnInit {
if (!this.loanDetailsForm.valid) {
this.validateAllFormFields(this.loanDetailsForm);
this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
const invalid = [];
const controls = this.loanDetailsForm.controls;
@ -888,8 +933,29 @@ export class LoanDetailsComponent implements OnInit {
this.disableAfterSubmit = false;
return;
}
console.log(this.loanDetailsForm);
console.log(this.loanDetailsForm.controls);
console.log('udhaya');
this.disableAfterSubmit = true;
let records: any = {};
if(this.lenderShortName=='CFPL')
{
alert('cfpl');
records.facility_amount = this.loanDetailsForm.controls['facility_amount'].value;
records.anchor_name = this.loanDetailsForm.controls['anchor_name'].value;
records.vintage_anchor_year = this.loanDetailsForm.controls['vintage_anchor_year'].value;
records.vintage_anchor_month = this.loanDetailsForm.controls['vintage_anchor_month'].value;
records.monthly_business_anchor = this.loanDetailsForm.controls['monthly_business_anchor'].value;
records.business_concentration = this.loanDetailsForm.controls['business_concentration'].value;
records.credit_period_days = this.loanDetailsForm.controls['credit_period_days'].value;
records.payment_mechanism = this.loanDetailsForm.controls['payment_mechanism'].value;
records.average_invoicevalue = this.loanDetailsForm.controls['average_invoicevalue'].value;
records.peakseasons_anchor = this.loanDetailsForm.controls['peakseasons_anchor'].value;
records.anchor_notes = this.loanDetailsForm.controls['anchor_notes'].value;
records.debitcredit_notes = this.loanDetailsForm.controls['debitcredit_notes'].value;
records.stock_related_anchor = this.loanDetailsForm.controls['stock_related_anchor'].value;
records.sample_invoices = this.loanDetailsForm.controls['sample_invoices'].value;
}
records.parent_pdid = this.parent_pdid;
records.pdid = this.pdid;
records.formid = this.form_id;
@ -986,9 +1052,13 @@ export class LoanDetailsComponent implements OnInit {
records.city=this.loanDetailsForm.controls['city'].value;
records.pincode=this.loanDetailsForm.controls['pincode'].value;
records.other_pincode=this.loanDetailsForm.controls['other_pincode'].value;
console.log(records);
console.log('latest');
this._pd.saveForm(records).subscribe(data => {
if (data.status == 200) {
console.log(data);
console.log('success');
this.notifier.notify('success', 'Saved Successfully.');
// this.dialogRef.close();
setTimeout(() => {