PageSourceSearch

https://npstrust.org.in/modules/custom/nps_vatsalya_calculator/js/vatsalya_details.js?v=1.x

js npstrust.org.in collected 2026-10-01 11:55:56 UTC 18,179 bytes, 425 lines download raw bytes

1(function ($, Drupal) {	
2    $(document).ready(function() {
3		
4		// $(".GraphBoxGridRow .GraphBoxGrid").hide();
5		function formatToIndianStyle(number) {
6			var numStr = number.toString();
7			var lastThree = numStr.substring(numStr.length - 3);
8			var otherNumbers = numStr.substring(0, numStr.length - 3);
9			if (otherNumbers !== '') {
10				lastThree = ',' + lastThree;
11			}
12			var result = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
13			return result;
14		}
15
16		function convertToCrores(number) {
17			// Convert the number to crores
18			let croreValue = number / 10000000;
19			return croreValue.toFixed(2) + " Cr";  // Rounded to two decimal places
20		}
21		function desiredMonthlyPension(total){
22			var amount = $("#vatsalyaMonthly").val().replace(/,/g, ''); // Required Monthly Pension
23			//console.log(amount);
24			var contribution = $("#edit-vatsalya-contribute-month").val().replace(/,/g, ''); 
25			//console.log(contribution);
26			var desired_length = amount.length;
27			
28			var pen_retir = total; // Actual gets Monthly Pension
29
30			// console.log("Actual gets Monthly Pension : "+pen_retir);
31			if(amount != ''){				
32				// console.log(pen_retir +" > = "+ amount);
33				if(parseInt(pen_retir) >= parseInt(amount)){
34					$(".err_dmp_msg .minValsValidation").remove();
35					// alert('You are on the right track. Keep Going!');return false;
36					$(".err_dmp_msg").append('<p class="mb-0 mt-2 minValsValidation pensionCalcRow alert-info">Your present monthly contribution is sufficient to achieve the desired corpus.</p>');
37					// $('.optionData').addClass('displayNone');
38				} else {
39					if ($(".optionData").hasClass("displayNone")) {	
40						$('.optionData').removeClass('displayNone');					
41					}
42					// console.log("VALS = "+ pensionContributeMonth);
43					if(contribution != ''){
44						var desired_val = Math.round(amount * contribution / pen_retir);
45						//console.log(desired_val);
46						var additionalCont = Math.round(desired_val - contribution); // Additional Contribution required
47						//console.log(additionalCont);
48						$("#increaseMonthamt").val(desired_val);
49						$(".monthContRander").html(formatToIndianStyle(Math.round(desired_val)));
50						vatsalyaincmonthlycontriution(Math.round(contribution),(parseInt(additionalCont)),Math.round(desired_val));
51					} else {
52						// console.log("HIDE CHART "+ pensionContributeMonth);
53						$(".optionData.ChOpt1").addClass('displayNone');
54					}
55					
56					$(".err_dmp_msg .minValsValidation").remove();
57				}
58			}else{
59				$('.optionData').addClass('displayNone');
60			}
61			
62		}
63		
64		
65		
66		// if($(".newpensionCalc").length) {
67		// 	$('.activeChoicepension').hide();
68			
69		// 	//My Existing NPS Tier 1 Corpus.focusout(function() {
70		// 	//$("#pensionCorpus").keyup(function(e){
71		// 	$("#pensionCorpus").focusout(function() {
72
73		// 		const number = parseInt($(this).val());
74		// 		$("#pensionexpectationRange").val(0);
75		// 		$('.expextInvestbtn').addClass('displayNone');	
76		// 		if (number < 0) {
77		// 			alert('Please enter only positive value');return false;
78		// 		}else{
79					
80		// 			var contri_per_month = $(this).val();
81		// 			var corpus_length = contri_per_month.length;
82		// 			if(corpus_length > 10){
83		// 				alert('Please enter only 9 digit corpus');
84		// 				$("#pensionnpsCorpus").text(0);
85		// 				$("#pensionCorpus").val(0);
86		// 				return false;
87		// 			}
88		// 			for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
89			
90		// 			if(contri_per_month == "") {
91		// 				document.getElementById("pensionCorpus").value = 0;
92		// 				document.getElementById("pensionCorpus").value = (document.getElementById("pensionCorpus").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
93		// 			}
94		// 			else {
95		// 				//var f1 = document.getElementById("id_txt4").value;
96		// 				for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
97						
98		// 				//var f2 = f1;
99		// 				document.getElementById("pensionCorpus").value = Number(contri_per_month);
100		// 				document.getElementById("pensionCorpus").value = (document.getElementById("pensionCorpus").value).toString();
101		// 				document.getElementById("pensionCorpus").value = (document.getElementById("pensionCorpus").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
102		// 			}
103					
104					
105		// 			//console.log(document.getElementById("edit-pension-contribute-month").value);
106		// 			$("#pensionnpsCorpus").text($(this).val());
107		// 		}
108			
109		// 	});
110		// }
111
112			// date of birth and retairment age slider
113	
114
115			
116			$('#expannuityeditedRange').focusout(function(){
117			//$('#expannuityeditedRange').on('input', function() {
118				var pannuity = $(this).val();
119				$('#pensioncustomRange5').val(pannuity);
120				var integerRegex = /^\d*(\.\d{0,2})?$/;
121
122				if (!integerRegex.test(pannuity)) {
123					// Remove any non-integer values (such as decimal points or non-numeric characters)
124					alert('Only value with 2 decimal are allowed.');
125					$('#pensioncustomRange5').val(6);
126					$("#expannuityeditedRange").val(6.73);
127					return false;
128				}
129				if(pannuity > 10){
130					alert('Please select expecting an annuity rate up 4 to 10');
131					$('#pensioncustomRange5').val(6);
132					$("#expannuityeditedRange").val(6.73);
133					return false;
134				}
135				if(pannuity < 4){
136					alert('Please select expecting an annuity rate up 4 to 10');
137					$('#pensioncustomRange5').val(6);
138					$("#expannuityeditedRange").val(6.73);
139					return false;
140				}
141
142			});
143			$("#pensioncustomRange5").change(function(e){
144				var pannuity = $(this).val();
145				$('#expannuityeditedRange').val(pannuity);
146			});
147			
148
149			//$('#pensionWithdrawalage').on('input', function() {
150			
151			$('#vatinvestRange').focusout(function() {
152			//$('#pensionexpectationRange').on('input', function() {
153				var expected = $(this).val();
154				$('#vatsalyacustomRange1').val($(this).val());
155				var integerRegex = /^\d*(\.\d{0,2})?$/;
156
157				if (!integerRegex.test(expected)) {
158					$('#vatsalyacustomRange1').val(12.21);
159					$("#vatinvestRange").val(12.21);
160					return false;
161				}
162				if(expected > 20){
163					alert('Please select projected return on investment up 0 to 20');
164					$('#vatsalyacustomRange1').val(12.21);
165					$("#vatinvestRange").val(12.21);
166					return false;
167				}
168				if(expected < 0){
169					alert('Please select projected return on investment up 0 to 20');
170					$('#vatsalyacustomRange1').val(12.21);
171					$("#vatinvestRange").val(12.21);
172					return false;
173				}
174			});
175			
176			//My expectation of return on investment is
177			$("#vatsalyacustomRange1").change(function(e){
178				$("#vatinvestRange").val($(this).val());
179			});
180
181			
182			
183
184		
185
186		
187		
188		$(".datapicker-nps-vatsalya").click(function(){
189			$("#pensionexpectationRange").val(0);
190			$('.expextInvestbtn').addClass('displayNone');	
191
192			
193		});
194		
195		$("#pensionMonthly").focusout(function() {
196			// console.log("==============");
197			var amount = $("#pensionMonthly").val(); // Required Monthly Pension
198			$("#pensionexpectationRange").val(0);
199			$('.expextInvestbtn').addClass('displayNone');	
200			if (amount < 0) {
201				alert('Please enter only positive value');return false;
202			}else{
203				var contri_per_month = amount;
204				var contribute_length = contri_per_month.length;
205					if(contribute_length > 8){
206						alert('Please enter only 7 digit desired monthly pension');
207						$("#pensionMonthly").val(0);
208						return false;
209					}
210				//var contrib_data = formatToIndianStyle(contri_per_month);
211				for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
212		
213				if(contri_per_month == "") {
214					document.getElementById("pensionMonthly").value = 0;
215					document.getElementById("pensionMonthly").value = (document.getElementById("pensionMonthly").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
216				}
217				else {
218					//var f1 = document.getElementById("id_txt4").value;
219					for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
220					
221					//var f2 = f1;
222					document.getElementById("pensionMonthly").value = Number(contri_per_month);
223					document.getElementById("pensionMonthly").value = (document.getElementById("pensionMonthly").value).toString();
224					document.getElementById("pensionMonthly").value = (document.getElementById("pensionMonthly").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
225				}
226			}
227			
228		});
229		
230		$("#vatsalya-calculator-form-submit").on("click", function (e) {
231			e.preventDefault(); //  MUST be active
232
233			var contribution = $('#edit-vatsalya-contribute-month').val();
234			if($('#edit-nps-vatsalya-date-of-birth').val() == '') {
235				alert('Please select the date of birth');
236				return false;
237			}
238			//  Validation FIRST
239			if (contribution === '' || contribution === '0') {
240				alert('Please enter the pension corpus or monthly contribution');
241				return false; //  STOP execution
242			}
243
244			// -------------------------------
245			// Continue only if valid
246			// -------------------------------
247			if ($(".pensionValueBox.TotalBox.blueBgColor.mb-4").hasClass("d-none")) {
248				$('.pensionValueBox').removeClass('d-none');
249				$('.npsCalVideoBox').addClass('displayNone');
250			}
251
252			var base_url = $('#base_url').val();
253			$(".vatsalyaCalcu").removeClass('displayNone');
254			$(".optionData").addClass('displayNone');
255
256			var age_vatsalya = 18;
257			var date_of_birth = $('#edit-nps-vatsalya-date-of-birth').val();
258			var amount = contribution.replace(/,/g, '');
259			var age = $('#vatsalyabirthYear').html().trim();
260			var expectation_invest = $('#vatinvestRange').val();
261
262			
263
264			var monthlyUrl1 =
265				base_url +
266				"vatsalya-calculator.php?sectorVal=nps_vatsalya&schemeVal=cg" +
267				"&birthVal=" + date_of_birth +
268				"&ageVal=" + age +
269				"&amount=" + amount +
270				"&retirementVal=" + age_vatsalya +
271				"&annualRate=0" +
272				"&withdrawalVal=" + age_vatsalya +
273				"&expectInvest=" + expectation_invest;
274
275			$.ajax({
276				url: monthlyUrl1,
277				cache: true,
278				dataType: 'json',
279				success: function (result_vat) {
280				var total = parseInt(result_vat.total);
281				var investment = parseInt(result_vat.investment);
282				var gain = total - investment;
283
284				$("#vatsalyatotalPension").val(total);
285				$("#vatsalyainvestment").val(investment);
286
287				desiredMonthlyPension(total);
288
289				$(".pensionValueBox .calvatsalyaTotal")
290					.text(formatToIndianStyle(Math.round(total)));
291
292				var chartData = prepareVatsalyaChartData(result_vat.vatsalya_array);
293				$(".GraphBoxGrid.ChOpt3").removeClass('displayNone');
294				renderTotalCorpusChart(chartData);
295				}
296			});
297			});
298		function prepareVatsalyaChartData(vatsalyaArray) {
299			var chartData = [];
300
301			$.each(vatsalyaArray, function (year, value) {
302				chartData.push({
303				year: parseInt(year),
304				value: Math.round(value)
305				});
306			});
307
308			return chartData;
309			}
310		$("#print-pension-calculator-detail").click(function(e){
311			e.preventDefault();
312			var base_url = $('#base_url').val();
313			//var sector_val_id = $('#edit-pension-sector-type option:selected').val(); // Get Sector
314			var sector_val_id = $("#edit-pension-sector-type input[type='radio']:checked").val(); // Get Sector
315			//var sector_val = $("#edit-pension-sector-type input[type='radio']:checked").next('label').text(); // Get Sector
316			//var sector_val = $('#edit-pension-sector-type option:selected').text(); // Get Sector
317			//var scheme_val = $('#edit-pension-scheme option:selected').text(); //// Get scheme in Sector wise
318			var scheme_val_id = $('#edit-pension-scheme option:selected').val();
319				
320			if(sector_val_id == 'nps_vatsalya'){
321				var date_of_birth = $('#edit-vatsalya-date-of-birth').val(); // Get Vatsalya date of birth
322			}else{
323				var date_of_birth = $('#edit-pension-date-of-birth').val(); // Get Gov and NON Gov sector date of birth
324			}
325			var age = $('#pensionbirthYear').html().trim(); // Get Age 
326			var retirement_age = $("#pensionretirementAge").val(); // Get retirement Age 
327			var dfr_age = $("#pension_withdrawal_age").val(); // Get withdrawal age 
328			var annual_rate = $("#pensionannualInc").val(); // Get Annual rate
329			var amount = $("#edit-pension-contribute-month").val().replace(/,/g, ''); // Get ammount
330			var corpusamount = $("#pensionCorpus").val().replace(/,/g, ''); // Get Corpus ammount
331			var purchase_annuty = $("#pensioncustomRange4").val(); // Get purachas annuty
332			var expectation_invest = $("#pensionexpectationRange").val(); // Get Expected Invaestment rate
333			var desiredPension = $("#pensionMonthly").val().replace(/,/g, ''); // Desired Pension
334			var annuity_rate = $("#expannuityeditedRange").val(); // Get annuity rate
335			var total = $("#edit-pension-corpus-retirement").val().replace(/,/g, ''); // Get Final Total
336			var investment = $("#pensiontotalIinvestment").val(); //// Get total investment
337			var pen_retir = $("#pensiontimeRetirement").val(); // Actual gets Monthly Pension
338			var amt_increase = $("#increaseMonthamt").val(); //Monthly increase ammount in chart
339			var proposed_annuity = $("#proposedAnnuitych").val(); // proposed annuity in chart
340			var pensionEquity = $("#pension_equity").val(); //active choice
341			var pensionGov = $("#pension_government_bond").val(); //active choice
342			var pensionCor = $("#pension_corporate_debt").val(); //active choice 
343			var pensionAlter = $("#pension_alternate_assets").val(); //active choice
344			//console.log(scheme_val);
345			//console.log(sectorVal);
346			if(scheme_val_id == 'ac'){
347				var printUrl = base_url+"pdf-download.php?rdm=ZHBjZGF0YWJ5c3R0bDExMjAyNA==&sectorVal_id="+sector_val_id+"&schemeVal_id="+scheme_val_id+"&pensionEquity="+pensionEquity+"&pensionGov="+pensionGov+"&pensionCor="+pensionCor+"&pensionAlter="+pensionAlter+"&birthVal="+date_of_birth+"&ageVal="+age+"&amount="+amount+"&corpusAmmount="+corpusamount+"&retirementVal="+retirement_age+"&annualRate="+annual_rate+"&withdrawalVal="+dfr_age+"&expectInvest="+expectation_invest+"&purchasAnnuty="+purchase_annuty+"&desiredPension="+desiredPension+"&annuityRate="+annuity_rate+"&finalTotal="+total+"&totalInvest="+investment+"&monthPension="+pen_retir+"&amtIncrease="+amt_increase+"&proposedAnnuity="+proposed_annuity;
348			}else{
349				var printUrl = base_url+"pdf-download.php?rdm=ZHBjZGF0YWJ5c3R0bDExMjAyNA==&sectorVal_id="+sector_val_id+"&schemeVal_id="+scheme_val_id+"&birthVal="+date_of_birth+"&ageVal="+age+"&amount="+amount+"&corpusAmmount="+corpusamount+"&retirementVal="+retirement_age+"&annualRate="+annual_rate+"&withdrawalVal="+dfr_age+"&expectInvest="+expectation_invest+"&purchasAnnuty="+purchase_annuty+"&desiredPension="+desiredPension+"&annuityRate="+annuity_rate+"&finalTotal="+total+"&totalInvest="+investment+"&monthPension="+pen_retir+"&amtIncrease="+amt_increase+"&proposedAnnuity="+proposed_annuity;
350			}
351			console.log(printUrl);
352			$('#print-pension-calculator-detail').addClass('displayNone');		
353			window.open(printUrl, '_blank');
354			// return printUrl;
355		});
356		$("#edit-vatsalya-contribute-month").focusout(function(e){
357			const number = parseInt($(this).val());
358			
359				var contri_per_month = $(this).val();
360				var contribute_length = contri_per_month.length;
361					if(contribute_length > 8){
362						alert('Please enter only 7 digit contribute');
363						$("#edit-vatsalya-contribute-month").val(0);
364						$("#vatsalyacontMonth").text(0);
365						return false;
366					}
367				//var contrib_data = formatToIndianStyle(contri_per_month);
368				for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
369		
370				if(contri_per_month == "") {
371					document.getElementById("edit-vatsalya-contribute-month").value = 0;
372					document.getElementById("edit-vatsalya-contribute-month").value = (document.getElementById("edit-vatsalya-contribute-month").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
373				}
374				else {
375					//var f1 = document.getElementById("id_txt4").value;
376					for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
377					
378					//var f2 = f1;
379					document.getElementById("edit-vatsalya-contribute-month").value = Number(contri_per_month);
380					document.getElementById("edit-vatsalya-contribute-month").value = (document.getElementById("edit-vatsalya-contribute-month").value).toString();
381					document.getElementById("edit-vatsalya-contribute-month").value = (document.getElementById("edit-vatsalya-contribute-month").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
382				}
383				
384				$("#vatsalyacontMonth").text($(this).val());
385	
386			
387		});
388		$("#vatsalyaMonthly").focusout(function(e){
389			const number = parseInt($(this).val());
390			
391				var contri_per_month = $(this).val();
392				var contribute_length = contri_per_month.length;
393					// if(contribute_length > 8){
394					// 	alert('Please enter only 7 digit contribute');
395					// 	$("#edit-vatsalya-contribute-month").val(0);
396					// 	$("#vatsalyacontMonth").text(0);
397					// 	return false;
398					// }
399				//var contrib_data = formatToIndianStyle(contri_per_month);
400				for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
401		
402				if(contri_per_month == "") {
403					document.getElementById("vatsalyaMonthly").value = 0;
404					document.getElementById("vatsalyaMonthly").value = (document.getElementById("vatsalyaMonthly").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
405				}
406				else {
407					//var f1 = document.getElementById("id_txt4").value;
408					for (ri = 0; ri <= 10; ri++) { contri_per_month = contri_per_month.replace(",", ""); }
409					
410					//var f2 = f1;
411					document.getElementById("vatsalyaMonthly").value = Number(contri_per_month);
412					document.getElementById("vatsalyaMonthly").value = (document.getElementById("vatsalyaMonthly").value).toString();
413					document.getElementById("vatsalyaMonthly").value = (document.getElementById("vatsalyaMonthly").value).replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");	
414				}
415				
416				$("#vatsalyaMonthly").text($(this).val());
417	
418			
419		});
420		
421    });
422	
423	
424})(jQuery, Drupal);
425

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.