Subversion Repositories SmartDukaan

Rev

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

Rev 27754 Rev 28395
Line 21... Line 21...
21
		$orderItemRow.find('.mfgdate').val(mfgDate);
21
		$orderItemRow.find('.mfgdate').val(mfgDate);
22
		$('#mobilePlansModal').modal('hide');
22
		$('#mobilePlansModal').modal('hide');
23
		calculateTotalAmount();
23
		calculateTotalAmount();
24
	});
24
	});
25
 
25
 
-
 
26
	//Price change handler
26
	$(document).on('change', "form#cd input.unitPrice", function() {
27
	$(document).on('change', "form#cd input.unitPrice,form#cd input.discount", function() {
27
		
28
		
28
		var unitPrice = parseFloat($(this).val());
29
		var unitPrice = parseFloat($('form#cd input.unitPrice').val());
29
		if (isNaN(unitPrice)){
30
		if (isNaN(unitPrice)){
30
			unitPrice = 0;
31
			unitPrice = 0;
31
		}
32
		}
-
 
33
		var discount = parseFloat($('form#cd input.discount').val());
-
 
34
		var maxDiscount = parseFloat($('form#cd input.discount').data('maxdiscount'));
32
		if(unitPrice < 0){
35
		if (isNaN(discount)){
-
 
36
			discount = 0;
-
 
37
		}
-
 
38
		if(isNaN(maxDiscount)) { 
-
 
39
			maxDiscount = 0;
-
 
40
		}
-
 
41
		if(discount > maxDiscount) {
-
 
42
			alert("Discount cant be greater than max Discount");
-
 
43
			$('form#cd input.discount').val(maxDiscount);
-
 
44
			$(this).focus();
-
 
45
			return;
-
 
46
		}
-
 
47
		if(unitPrice < 0 || (unitPrice > 0 && unitPrice - discount < 0)){
33
			alert("Invalid unit price");
48
			alert("Invalid unit/discount price");
34
			$(this).val(0);
49
			$(this).focus();
-
 
50
			return;
35
		}
51
		}
36
		
52
		
37
		calculateTotalAmount();
53
		calculateTotalAmount();
38
	});
54
	});
39
	
55
	
Line 50... Line 66...
50
		$('div.itemdetails').find('input').val('');
66
		$('div.itemdetails').find('input').val('');
51
		var mop = parseFloat($(this).data("mop"));
67
		var mop = parseFloat($(this).data("mop"));
52
		var sellingPrice = $(this).val();
68
		var sellingPrice = $(this).val();
53
		var itemId = $(this).closest(".input-group").find("input.insuranceamount").attr("itemid");
69
		var itemId = $(this).closest(".input-group").find("input.insuranceamount").attr("itemid");
54
		if(!isNaN(sellingPrice) && parseFloat(sellingPrice) >= mop){
70
		if(!isNaN(sellingPrice) && parseFloat(sellingPrice) >= mop){
55
			price = paeseFloat(sellingPrice);
71
			price = parseFloat(sellingPrice);
56
		} else {
72
		} else {
57
			price = mop;
73
			price = mop;
58
		}
74
		}
-
 
75
		var discount = parseFloat($(this).closest("tr").find("input.discount").val());
-
 
76
		if(!isNaN(discount)) {
-
 
77
			price = price - discount;
-
 
78
		}
59
		that = this;
79
		that = this;
60
		doGetAjaxRequestHandler(context+"/checkplans?price=" + price + "&itemId=" + itemId, function(response){
80
		doGetAjaxRequestHandler(context+"/checkplans?price=" + price + "&itemId=" + itemId, function(response){
61
			var obj = JSON.parse(response);
81
			var obj = JSON.parse(response);
62
			getInsurancePlansModal(obj);
82
			getInsurancePlansModal(obj);
63
			planCheckedOn = that;
83
			planCheckedOn = that;
Line 116... Line 136...
116
		}else{
136
		}else{
117
			insuranceAmount = parseFloat(insuranceAmount);
137
			insuranceAmount = parseFloat(insuranceAmount);
118
		}
138
		}
119
		
139
		
120
		var quantity = parseFloat($(el).find('.unitPrice').attr('quantity'));
140
		var quantity = parseFloat($(el).find('.unitPrice').attr('quantity'));
121
		if(isNaN(quantity)){
-
 
122
			quantity = 0;
-
 
123
		}
-
 
124
		console.log("quantity : "+quantity);
-
 
125
		
141
		
126
		var unitPrice = parseFloat($(el).find('.unitPrice').val());
142
		var unitPrice = parseFloat($(el).find('.unitPrice').val());
127
		if(isNaN(unitPrice)){
143
		if(isNaN(unitPrice)){
128
			unitPrice = 0;
144
			unitPrice = 0;
129
		}
145
		}
-
 
146
		
130
		console.log("unitPrice : "+unitPrice);
147
		var discount = $(el).find('.discount').val();
-
 
148
		if(isNaN(discount)){
-
 
149
			discount = 0;
-
 
150
		}
131
 
151
 
132
		rowTotal = unitPrice * quantity + insuranceAmount; 
152
		rowTotal = unitPrice - discount + insuranceAmount; 
133
		$tr.find('.totalPrice').val(rowTotal);
153
		$tr.find('.totalPrice').val(rowTotal);
134
		netPayableAmount += rowTotal;
154
		netPayableAmount += rowTotal;
135
		totaInsuranceAmount += insuranceAmount;
155
		totaInsuranceAmount += insuranceAmount;
136
	});
156
	});
137
	if(totaInsuranceAmount > 0) {
157
	if(totaInsuranceAmount > 0) {