Subversion Repositories SmartDukaan

Rev

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

Rev 23783 Rev 23820
Line 78... Line 78...
78
	});
78
	});
79
    
79
    
80
	$("input.unitPrice").blur(function() {
80
	$("input.unitPrice").blur(function() {
81
		console.log("unitPrice blur called");
81
		console.log("unitPrice blur called");
82
		var $element = $(this);
82
		var $element = $(this);
83
		var unitPrice = $element.val();
83
		var unitPrice = parseFloat($element.val());
-
 
84
		if(!isNaN(unitPrice)) {
84
		var mopPrice = parseFloat($(this).attr('mopPrice'));
85
			var mopPrice = parseFloat($(this).attr('mopPrice'));
-
 
86
			var dp = parseFloat($(this).attr('dp'));
85
		if(parseFloat(unitPrice) < mopPrice){
87
			if(!accessoriesDeals && unitPrice < mopPrice){
-
 
88
				alert("Selling Price must be greater than equal to MOP")
-
 
89
				$element.addClass("border-highlight");
86
			//error = true;
90
			}else if(unitPrice < dp){
87
			alert("sellingPrice must be greater than equal to mop")
91
				alert("Selling Price must be greater than equal to Purchase Price")
88
			$element.addClass("border-highlight");
92
				$element.addClass("border-highlight");
89
		}else{
93
			}else{
90
			$element.removeClass("border-highlight")
94
				$element.removeClass("border-highlight")
91
			if(unitPrice == mopPrice){
95
				if(unitPrice == mopPrice){
92
				$("input.discountAmount").removeAttr("readonly");
96
					$("input.discountAmount").removeAttr("readonly");
93
			}
97
				}
94
			if(unitPrice != ''){
-
 
95
				doAjaxRequestHandler(context+"/insurancePrices?price="+unitPrice, "GET", function(response){
98
				doAjaxRequestHandler(context+"/insurancePrices?price="+unitPrice, "GET", function(response){
96
					console.log("response : "+JSON.stringify(response));
99
					console.log("response : "+JSON.stringify(response));
97
					var insurancePriceMap = response.response;
100
					var insurancePriceMap = response.response;
98
					for(key in insurancePriceMap){
101
					for(key in insurancePriceMap){
99
						var dealerPrice = insurancePriceMap[key].dealerPrice;
102
						var dealerPrice = insurancePriceMap[key].dealerPrice;
100
						var sellingPrice = insurancePriceMap[key].sellingPrice;
103
						var sellingPrice = insurancePriceMap[key].sellingPrice;
101
						$element.closest('tr').find('.insuranceAmount').attr("placeholder", dealerPrice + "-" + sellingPrice);
104
						$element.closest('tr').find('.insuranceAmount').attr("placeholder", dealerPrice + "-" + sellingPrice);
102
						break;
105
						break;
103
					}
106
					}
104
				});
107
				});
105
		    }
108
			}
106
		}
109
		}
107
	}).focus(function(){
110
	}).focus(function(){
108
		console.log("unitPrice focus called");
111
		console.log("unitPrice focus called");
109
		var $element = $(this);
112
		var $element = $(this);
110
		$element.closest('tr').find('.insuranceAmount').attr("placeholder", "");
113
		$element.closest('tr').find('.insuranceAmount').attr("placeholder", "");
Line 149... Line 152...
149
		$(this).removeClass("border-highlight");
152
		$(this).removeClass("border-highlight");
150
		if (!input || parseInt(input)<=0 || isNaN(input)){
153
		if (!input || parseInt(input)<=0 || isNaN(input)){
151
			error=true;
154
			error=true;
152
			$(this).addClass("border-highlight");
155
			$(this).addClass("border-highlight");
153
		}
156
		}
154
		var unitPrice = parseFloat(input);
-
 
155
		var mopPrice = parseFloat($(this).attr('mopPrice'));
-
 
156
		if(unitPrice < mopPrice){
-
 
157
			error = true;
-
 
158
			alert("sellingPrice must be greater than equal to mop")
-
 
159
			$(this).addClass("border-highlight");
-
 
160
		}
-
 
161
	});
157
	});
162
	
158
	
163
	// checking input discountAmount is not greater than maxDiscountAmount
159
	// checking input discountAmount is not greater than maxDiscountAmount
164
	$("form#cd input.discountAmount").each(function(){
160
	$("form#cd input.discountAmount").each(function(){
165
		var input = $(this).val().trim();
161
		var input = $(this).val().trim();