Subversion Repositories SmartDukaan

Rev

Rev 9145 | Rev 9152 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9145 Rev 9149
Line 24... Line 24...
24
	 	9:"/images/sbi-icon.png",
24
	 	9:"/images/sbi-icon.png",
25
	};
25
	};
26
 
26
 
27
 
27
 
28
	var minEmi = 999999;
28
	var minEmi = 999999;
-
 
29
	if(typeof EMI === "undefined"){
-
 
30
		EMI={};
-
 
31
	}
-
 
32
	EMI.lowestEmiBank = 0;
29
	jQuery.each(emiObj, function(index, opt) {
33
	jQuery.each(emiObj, function(index, opt) {
30
		if(sellingPrice >= opt.minAmount){ 
34
		if(sellingPrice >= opt.minAmount){ 
31
			if(typeof banks[opt.bankId] == "undefined") {
35
			if(typeof banks[opt.bankId] == "undefined") {
32
				banks[opt.bankId] = {};
36
				banks[opt.bankId] = {};
33
				banks[opt.bankId].name =  opt.bankName;
37
				banks[opt.bankId].name =  opt.bankName;
Line 40... Line 44...
40
			bankTenure.tenureDescription = opt.tenureDescription;
44
			bankTenure.tenureDescription = opt.tenureDescription;
41
			var r = opt.interestRate/12/100;
45
			var r = opt.interestRate/12/100;
42
			var installment = sellingPrice*r*Math.pow(1+r,opt.tenure)/(Math.pow(1+r,opt.tenure) - 1);
46
			var installment = sellingPrice*r*Math.pow(1+r,opt.tenure)/(Math.pow(1+r,opt.tenure) - 1);
43
			bankTenure.monthlyEmi =  (Math.round(installment*100)/100).toFixed(2);
47
			bankTenure.monthlyEmi =  (Math.round(installment*100)/100).toFixed(2);
44
			bankTenure.interestRate = opt.interestRate;
48
			bankTenure.interestRate = opt.interestRate;
45
			if(minEmi > bankTenure.monthlyEmi){
49
			if(minEmi > installment){
46
				minEmi = bankTenure.monthlyEmi;
50
				minEmi = installment;
-
 
51
				EMI.lowestEmiBank = opt.bankId;
47
			}
52
			}
48
			bank.emis[opt.id] = bankTenure;
53
			bank.emis[opt.id] = bankTenure;
49
		}
54
		}
50
	});
55
	});
51
	jQuery.each(banks, function(index, bank){
56
	jQuery.each(banks, function(index, bank){
Line 68... Line 73...
68
    		width:"600px",
73
    		width:"600px",
69
    		height:"410px",
74
    		height:"410px",
70
    		
75
    		
71
    		onComplete: function(){
76
    		onComplete: function(){
72
    			$('#emiLightBox').show();
77
    			$('#emiLightBox').show();
-
 
78
    			if(EMI.lowestEmiBank == 0) {
73
    			bankEle.find("input[type='radio']:first").trigger('click');
79
    				bankEle.find("input[type='radio']:first").trigger('click');
-
 
80
    			}
-
 
81
    			else {
-
 
82
    				bankEle.find("input[type='radio']).find("#" + EMI.lowestEmiBank).trigger('click');
-
 
83
    			}
74
    		},
84
    		},
75
    		onCleanup: function(){
85
    		onCleanup: function(){
76
    			$('#emiLightBox').hide();
86
    			$('#emiLightBox').hide();
77
    		}
87
    		}
78
    	});
88
    	});