Subversion Repositories SmartDukaan

Rev

Rev 32192 | Rev 32256 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
32145 tejbeer 1
$(function() {
2
	$(document).on('click', ".warehouse-create-purchase-order", function() {
3
		loadCreatePurchase("main-content");
4
	});
5
 
6
 
32192 tejbeer 7
	$(document).on('click', ".warehouse-receive-new-invoice", function() {
8
		loadNewReceiveInvoice("main-content");
9
	});
32145 tejbeer 10
 
32192 tejbeer 11
 
12
 
13
 
14
 
15
 
16
 
17
	$(document)
18
		.on(
19
			'input',
20
			'#invoice',
21
			function() {
22
				if (confirm('Document has been selected, Do you want to upload ?')) {
23
					var fileSelector = $('#invoice')[0];
24
					if (fileSelector != undefined
25
						&& fileSelector.files[0] != undefined) {
26
						var url = context + '/document-upload';
27
 
28
						console.log(url);
29
						var file = this.files[0];
30
						doAjaxUploadRequestHandler(
31
							url,
32
							'POST',
33
							file,
34
							function(response) {
35
								console.log(response);
36
								var documentId = response.response.document_id;
37
								console.log("documentId : "
38
									+ documentId);
39
								$("#invoicehidden").val(documentId);
40
							});
41
 
42
					}
43
				} else {
44
					// Do nothing!
45
				}
46
			});
47
 
48
	$(document).on('click', ".createReceiveInvoice", function() {
49
 
50
		var invoiceDate = $('#actualDate').val();
51
 
52
		var warehouseId = $('#warehouseMap').val();
53
 
54
		var numItems = $('#numberofItems').val();
55
 
56
		var receivedBy = $('#authUser').val();
57
 
58
		var supplierId = $('#vendorId').val();
59
 
60
		var totalValue = $('#totalValue').val();
61
 
62
		var invoiceNumber = $('#invoiceNumber').val();
63
 
64
 
65
		var invoiceDoc = $("#invoicehidden").val();
66
 
67
 
68
		console.log(invoiceDoc)
69
 
70
 
71
		if (invoiceDate === "" && warehouseId === "" && numItems === "" && receivedBy === "" && supplierId === "" && totalValue === "" && invoiceNumber === "" && invoiceDoc === "") {
72
			alert("Field can't be empty");
73
			return false;
74
		}
75
 
76
 
77
		if (invoiceDate === "") {
78
			alert("please select date");
79
			return false;
80
		}
81
		if (warehouseId === "") {
82
			alert("please choose warehouse");
83
			return false;
84
		}
85
 
86
		if (numItems === "") {
87
			alert("please fill number of items.");
88
			return false;
89
		}
90
		if (receivedBy === "") {
91
			alert("please choose received by  user");
92
			return false;
93
		}
94
 
95
		if (supplierId === "") {
96
			alert("please choose supplier");
97
			return false;
98
		}
99
 
100
 
101
 
102
		if (totalValue === "") {
103
			alert("please fill Total Value.");
104
			return false;
105
		}
106
 
107
		if (invoiceNumber === "") {
108
			alert("please fill Invoice Number.");
109
			return false;
110
		}
111
 
112
 
113
		if (invoiceDoc === "") {
114
			alert("please upload invoice.");
115
			return false;
116
		}
117
		var newReceiveInvoice = {};
118
 
119
		newReceiveInvoice['invoiceDate'] = invoiceDate;
120
		newReceiveInvoice['warehouseId'] = warehouseId
121
		newReceiveInvoice['numItems'] = numItems
122
		newReceiveInvoice['receivedBy'] = receivedBy
123
		newReceiveInvoice['supplierId'] = supplierId
124
		newReceiveInvoice['totalValue'] = totalValue
125
		newReceiveInvoice['invoiceNumber'] = invoiceNumber
126
		newReceiveInvoice['invoiceDoc'] = invoiceDoc
127
 
128
		if (confirm("Are you sure you want to add new Invoice") == true) {
129
 
130
			doPostAjaxRequestWithJsonHandler(context
131
				+ "/newReceiveInvoice", JSON
132
					.stringify(newReceiveInvoice), function(response) {
133
						if (response == 'true') {
134
							alert("successfully added");
135
							loadNewReceiveInvoice("main-content");
136
						}
137
					});
138
		}
139
 
140
 
141
 
142
 
143
 
144
	});
145
 
146
 
147
 
32145 tejbeer 148
	$(document).on('click', ".purchaseorderitemview", function() {
149
 
150
		var vendorId = $('#vendorId').val();
151
		var warehouseId = $('#warehouseMap').val();
152
 
153
		console.log(warehouseId)
154
 
155
		if (warehouseId == null && vendorId === "") {
156
			alert("Field can't be empty");
157
			return;
158
		}
159
 
160
 
161
		if (warehouseId == null) {
162
			alert("please select warehouse");
163
			return;
164
		}
165
		if (vendorId === "") {
166
			alert("please select vendor");
167
			return;
168
		}
169
		doGetAjaxRequestHandler(context + "/addPurchaseItemView?warehouseId=" + warehouseId + "&vendorId=" + vendorId, function(response) {
170
			$(".createpurchaseordercontainer").html(response);
171
		});
172
	});
173
 
174
 
175
	$(document).on('click', ".addRowInPurchaseOrder", function() {
32192 tejbeer 176
 
177
 
178
		var purchaseItemIds = [];
179
		var totalQty = 0
180
 
181
		$("table > tbody > tr").each(function() {
182
			var itemId = $(this).find(".transferPrice").data('itemid');
183
			var qty = $(this).find(".qty").val();
184
 
185
			console.log(qty)
186
 
187
			if (qty != undefined) {
188
				totalQty += parseInt(qty)
189
			}
190
 
191
			console.log(totalQty)
192
 
193
 
194
			if (itemId != undefined) {
195
				purchaseItemIds.push(itemId)
196
			}
197
		});
198
 
32145 tejbeer 199
		var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td> <td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td><td>  <input type="number" class="form-control transferPrice"  disable placeholder="Transfer Price"/> </td>	<td>  <input type="number" class="form-control totalValue"  disable placeholder="Total Value"/> </td> <td> <input class="form-control btn btn-primary removeInPurchaseOrder" type="button" value="Remove"></td>  </tr> ');
200
 
32195 tejbeer 201
		var vendorId = $('#vendorId').val();
32145 tejbeer 202
 
32192 tejbeer 203
 
32195 tejbeer 204
		getVendorItemAheadOptions($html.find('.typeaheaditem'), vendorId, function(
32145 tejbeer 205
			selectedItem) {
206
			var itemId = selectedItem.itemId;
207
 
32192 tejbeer 208
			if (purchaseItemIds.indexOf(itemId) > -1) {
32145 tejbeer 209
				alert("item already selected");
210
				$html.find('.typeaheaditem').val("")
211
 
212
				return false;
213
			}
214
 
32192 tejbeer 215
			purchaseItemIds.push(itemId)
32145 tejbeer 216
 
217
 
218
 
219
			doGetAjaxRequestHandler(context + "/getPricing?vendorId=" + vendorId + "&itemId=" + itemId, function(response) {
220
				console.log(response)
221
				if (response != "null") {
222
					var jsonObj = JSON.parse(response);
223
 
224
					console.log(jsonObj)
225
					$html.find('.transferPrice').val(jsonObj.transferPrice)
226
 
227
					$html.find('.transferPrice').data('itemid', itemId)
228
				} else {
229
 
230
					console.log(response)
231
					$html.find('.typeaheaditem').val("")
232
 
233
				}
234
			});
235
 
236
		});
237
		$('tbody').append($html);
238
 
239
	});
240
 
241
	$(document).on('click', '.createSendPurchaseOrder', function() {
242
 
243
		createPurchase(true);
244
 
245
	});
246
 
247
 
248
	$(document).on('click', '.createPurchaseOrder', function() {
249
 
250
 
251
		createPurchase(false);
252
	});
253
 
254
 
255
	$(document).on('change', '.qty', function() {
256
 
257
 
258
		var row = $(this).closest("tr");
259
		var qty = $(row).find(".qty").val();
260
		var transferPrice = $(row).find(".transferPrice").val();
261
 
262
		var totalVal = transferPrice * qty;
263
 
264
		var totalValue = $(row).find(".totalValue").val(totalVal);
265
 
266
		var purchaseOrderValue = 0;
267
 
268
		$("table > tbody > tr").each(function() {
269
 
270
			var totalValue = $(this).find(".totalValue").val();
271
			purchaseOrderValue += totalValue
272
 
273
		});
274
 
275
	});
276
 
277
 
278
 
279
 
280
	$(document).on('click', '.warehouse-open-purchase-order', function() {
281
		loadOpenPurchase("main-content");
282
	});
283
 
284
 
285
 
286
	$(document).on('click', '.editViewPurchaseOrder', function() {
287
		var purchaseOrderId = $(this).data('poid');
288
		doGetAjaxRequestHandler(context + "/getEditPOByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
289
			$('#warehouseEditPurchaseContainer .modal-content').html(response);
290
		});
291
 
292
	});
293
 
294
	$(document).on('click', '.editPurchaseOrder', function() {
295
		var purchaseOrderId = $(this).data('poid');
296
 
297
		editPurchase(true, purchaseOrderId);
298
 
299
	});
300
 
301
 
302
	$(document).on('click', '.editSendPurchaseOrder', function() {
303
		var purchaseOrderId = $(this).data('poid');
304
 
305
 
306
		editPurchase(false, purchaseOrderId);
307
	});
308
 
309
	$(document).on('click', '.closePurchaseOrder', function() {
310
		var purchaseOrderId = $(this).data('poid');
311
		if (confirm("Are you sure you want to close the PO") == true) {
312
			doPostAjaxRequestHandler(context + "/closePuchaseOrder?purchaseId=" + purchaseOrderId,
313
				function(response) {
314
 
315
					console.log(response);
316
					if (response == 'true') {
317
						alert("successfully closed");
318
						loadOpenPurchase("main-content")
319
					}
320
				});
321
		}
322
	});
323
 
324
 
325
	$(document).on('click', '.warehouse-view-purchase-order', function() {
326
		doGetAjaxRequestHandler(context + "/viewPurchaseOrder", function(response) {
327
			$('#' + 'main-content').html(response);
328
		});
329
	});
330
 
331
 
332
 
32192 tejbeer 333
 
334
 
32145 tejbeer 335
	$(document).on('click', '.dateWisePo', function() {
336
 
337
		var startDate = getDatesFromPicker('input[name="duration"]').startDate;
338
		var endDate = getDatesFromPicker('input[name="duration"]').endDate
339
 
340
 
341
		doGetAjaxRequestHandler(context + "/getPurchaseOrders?startDate=" + startDate + "&endDate=" + endDate, function(response) {
342
			$('.purchaseorderviewcontainer').html(response);
343
 
344
		});
345
 
346
 
347
	});
348
 
349
 
350
 
351
	$(document).on('click', '.viewPurchaseOrderlineItem', function() {
352
		var purchaseOrderId = $(this).data('poid');
353
 
354
		doGetAjaxRequestHandler(context + "/getWarehouseLineItemByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
355
			$('#warehouseLineItem .modal-content').html(response);
356
 
357
		});
358
	});
359
 
360
 
361
 
32192 tejbeer 362
 
363
	$(document).on("click", '.removeInPurchaseOrder', function() {
364
 
365
		var row = $(this).closest("tr");
366
		row.remove();
367
	});
368
 
369
	$(document).on('click', ".addRowForInvoiceItem", function() {
370
 
371
		var numitems = $(this).data("numitems");
372
		var invoiceId = $(this).data("invoiceid");
373
 
374
 
375
		var invoiceItemIds = [];
376
		var totalQty = 0
377
 
378
		$("#invoice-order-table > tbody > tr").each(function() {
379
			var itemId = $(this).find(".rate").data('itemid');
380
			var qty = $(this).find(".qty").val();
381
 
382
			console.log(qty)
383
 
384
			if (qty != undefined) {
385
				totalQty += qty
386
			}
387
 
388
			console.log(totalQty)
389
 
390
 
391
			if (itemId != undefined) {
392
				invoiceItemIds.push(itemId)
393
			}
394
		});
395
 
396
		var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td>' +
397
			'<td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td>' +
398
			'<td>  <input type="number" class="form-control rate"  disable placeholder="Rate"/> </td>' +
399
			'<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td>  </tr> ');
400
 
401
 
402
		getItemAheadOptions($html.find('.typeaheaditem'), true, function(
403
			selectedItem) {
404
			var itemId = selectedItem.itemId;
405
 
406
 
407
			console.log(invoiceItemIds)
408
 
409
			if (invoiceItemIds.indexOf(itemId) > -1) {
410
				alert("item already selected");
411
				$html.find('.typeaheaditem').val("")
412
 
413
				return false;
414
			}
415
			$html.find('.rate').data('itemid', itemId)
416
 
417
			$html.find('.removeInInvoiceItem').data('invoiceid', invoiceId)
418
			$html.find('.removeInInvoiceItem').data('itemid', itemId)
419
 
420
		});
421
 
422
 
423
		if (totalQty < numitems) {
424
 
425
			$('#invoice-order-table tbody').append($html);
426
		}
427
 
428
	});
429
 
430
 
431
 
432
 
433
 
434
	$(document).on('click', '.saveInvoiceDetail', function() {
435
 
436
		var numItems = $(this).data("numitems");
437
		var invoiceId = $(this).data("invoiceid");
438
		var warehouseId = $(this).data("warehouseid");
439
		var supplierId = $(this).data("supplierid");
440
		getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, false);
441
 
442
	});
443
 
444
 
445
 
446
	$(document).on('click', '.validateInvoiceDetail', function() {
447
		var numItems = $(this).data("numitems");
448
		var invoiceId = $(this).data("invoiceid");
449
		var warehouseId = $(this).data("warehouseid");
450
		var supplierId = $(this).data("supplierid");
451
 
452
		getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, true);
453
 
454
	});
455
 
456
 
457
	$(document).on("click", '.removeInInvoiceItem', function() {
458
 
459
		var row = $(this).closest("tr");
460
		var invoiceId = $(this).data("invoiceid");
461
		var itemId = $(this).data("itemid");
462
		if (invoiceId != undefined && itemId != undefined) {
463
			doDeleteAjaxRequestHandler(context + "/removeInvoiceItem?invoiceId="
464
				+ invoiceId + "&itemId=" + itemId, function(response) {
465
					if (response == "true") {
466
						alert("Item removed successfully");
467
 
468
					}
469
				});
470
		}
471
 
472
		row.remove();
473
 
474
	});
475
 
476
 
477
	$(document).on('click', '.purchaseGrn', function() {
478
 
479
		var grnItemArray = [];
480
 
481
		var invoiceId = $(this).data("invoiceid");
482
 
483
 
484
		$("#invoice-purchase-validate > tbody > tr").each(function() {
485
			var grnItemJson = {};
486
 
487
			var itemId = $(this).find(".itemId").text();
488
			var qty = $(this).find(".qty").text();
489
			var poId = $(this).find(".purchaseId").text();
490
 
491
			var itemType = $(this).find(".itemType").text();
492
 
493
			console.log(itemType);
494
 
495
			if (itemType == "Serialized") {
496
				var serialNumbers = $(".imeis-to-grn").tagsinput('items');
497
				grnItemJson['serialNumbers'] = serialNumbers
498
 
499
			}
500
			console.log(serialNumbers)
501
			grnItemJson['itemId'] = itemId;
502
			grnItemJson['serialNumbers'] = serialNumbers
503
			grnItemJson['qty'] = qty
504
			grnItemJson['poId'] = poId
505
			grnItemJson['invoiceId'] = invoiceId
506
			grnItemArray.push(grnItemJson)
507
 
508
			console.log(grnItemArray)
509
 
510
		});
511
 
512
		for (var i = 0; i < grnItemArray.length; i++) {
513
 
514
			var serialNumbers = grnItemArray[i].serialNumbers.length
515
 
516
			if (serialNumbers > 0) {
517
 
518
				var serialNumbers = grnItemArray[i].serialNumbers.length
519
				var qty = grnItemArray[i].qty
520
 
521
				if (serialNumbers != qty) {
522
					alert("serial number is not matched with qty")
523
					return false;
524
				}
525
			}
526
 
527
		}
528
 
529
 
530
		console.log(JSON.stringify(grnItemArray))
531
		if (confirm("Are you sure you want to grn purchase order") == true) {
532
 
533
			doPostAjaxRequestWithJsonHandler(context
534
				+ "/createGrn", JSON
535
					.stringify(grnItemArray), function(response) {
536
						if (response == 'true') {
537
							alert("successfully done");
538
						}
539
					});
540
		}
541
 
542
 
543
 
544
	});
545
 
546
 
32145 tejbeer 547
});
548
 
549
function loadCreatePurchase(domId) {
550
	doGetAjaxRequestHandler(context + "/warehousePurchaseOrder", function(response) {
551
		$('#' + domId).html(response);
552
	});
553
}
554
 
32192 tejbeer 555
 
556
 
32145 tejbeer 557
function loadOpenPurchase(domId) {
558
 
559
	doGetAjaxRequestHandler(context + "/getOpenPurchaseOrder", function(response) {
560
		$('#' + domId).html(response);
561
	});
562
}
563
 
32192 tejbeer 564
function loadNewReceiveInvoice(domId) {
565
	doGetAjaxRequestHandler(context + "/newReceiveInvoice", function(response) {
566
		$('#' + domId).html(response);
567
	});
568
}
569
 
32145 tejbeer 570
function createPurchase(sendPo) {
571
	var purchaseOrder = {};
572
 
573
	var vendorId = $('#vendorId').val();
574
 
575
	var warehouseId = $('#warehouseMap').val();
576
 
577
 
578
	var items = []
579
	$("table > tbody > tr").each(function() {
580
		var purchaseOrderJson = {};
581
 
582
		var itemId = $(this).find(".transferPrice").data('itemid');
583
		var qty = $(this).find(".qty").val();
584
		var transferPrice = $(this).find(".transferPrice").val();
585
		var totalValue = $(this).find(".totalValue").val();
586
 
587
 
588
		purchaseOrderJson['itemId'] = itemId;
589
		purchaseOrderJson['qty'] = qty
590
		purchaseOrderJson['totalValue'] = totalValue
591
		purchaseOrderJson['transferPrice'] = transferPrice
592
 
593
		items.push(purchaseOrderJson)
594
	});
595
 
596
 
597
	for (var i = 0; i < items.length; i++) {
598
		console.log(items[i])
599
 
600
		var itemId = items[i].itemId
601
		var qty = items[i].qty
602
		var transferPrice = items[i].transferPrice
603
		var totalValue = items[i].totalValue
604
 
605
		if (itemId === "" && qty === "" && transferPrice === "" && totalValue === "") {
606
			alert("Field can't be empty");
607
			return false;
608
		}
609
 
610
 
611
		if (itemId === "") {
612
			alert("please select item");
613
			return false;
614
		}
615
		if (qty === "") {
616
			alert("please choose qty");
617
			return false;
618
		}
619
 
620
		if (transferPrice === "") {
621
			alert("Transfer Price can't be empty");
622
			return false;
623
		}
624
		if (totalValue === "") {
625
			alert("Total value can't be empty");
626
			return false;
627
		}
628
 
629
 
630
 
631
	}
632
 
633
	purchaseOrder['vendorId'] = vendorId;
634
	purchaseOrder['warehouseId'] = warehouseId
635
	purchaseOrder['sendPo'] = sendPo
636
 
637
	purchaseOrder['items'] = items
638
 
639
	console.log(purchaseOrder)
640
 
641
 
642
 
643
	if (confirm("Are you sure you want to create purchase order") == true) {
644
 
645
		doPostAjaxRequestWithJsonHandler(context
646
			+ "/createPurchaseOrder", JSON
647
				.stringify(purchaseOrder), function(response) {
648
					if (response == 'true') {
649
						alert("successfully created");
650
					}
651
				});
652
	}
653
 
654
}
655
 
656
 
657
function editPurchase(sendPo, poid) {
658
	var editpurchaseOrder = {}
659
	var items = []
660
	$("#purchase-edit-lineitem > tbody > tr").each(function() {
661
		var purchaseOrderJson = {};
662
		var itemId = $(this).find("td:eq(0)").text();
663
 
664
		var qty = $(this).find(".editqty").val();
665
 
666
		purchaseOrderJson['itemId'] = itemId;
667
		purchaseOrderJson['qty'] = qty
668
 
669
		items.push(purchaseOrderJson)
670
	});
671
 
672
 
673
	for (var i = 0; i < items.length; i++) {
674
		console.log(items[i])
675
 
676
		var qty = items[i].qty
677
 
678
		if (qty === "") {
679
			alert("please choose qty");
680
			return false;
681
		}
682
 
683
		if (qty < 0) {
684
			alert("Quantity should be greater than 0");
685
			return false;
686
		}
687
 
688
 
689
	}
690
 
691
	editpurchaseOrder['purchaseOrderId'] = poid;
692
	editpurchaseOrder['sendPo'] = sendPo
693
	editpurchaseOrder['items'] = items
694
 
695
 
696
	if (confirm("Are you sure you want to edit purchase order") == true) {
697
 
698
		doPostAjaxRequestWithJsonHandler(context
699
			+ "/editPurchaseOrder", JSON
700
				.stringify(editpurchaseOrder), function(response) {
701
					if (response == 'true') {
702
						alert("successfully created");
703
					}
704
				});
705
	}
706
 
707
}
708
 
709
 
32192 tejbeer 710
function getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, validate) {
711
 
712
	var invoiceJson = {};
713
	console.log(numItems)
714
	var totalQty = 0;
715
	var invoiceItems = []
716
	$("#invoice-order-table > tbody > tr").each(function() {
717
		var invoiceItemJson = {};
718
		var itemId = $(this).find(".rate").data('itemid');
719
		var qty = $(this).find(".qty").val();
720
 
721
		if (qty != undefined) {
722
			totalQty += parseInt(qty)
723
		}
724
		var rate = $(this).find(".rate").val();
725
		invoiceItemJson['itemId'] = itemId;
726
		invoiceItemJson['qty'] = qty
727
		invoiceItemJson['rate'] = rate
728
		invoiceItems.push(invoiceItemJson)
729
	});
730
 
731
 
732
	for (var i = 0; i < invoiceItems.length; i++) {
733
 
734
		var itemId = invoiceItems[i].itemId
735
		var qty = invoiceItems[i].qty
736
		var rate = invoiceItems[i].rate
737
		if (itemId === "" && qty === "" && rate === "") {
738
			alert("Field can't be empty");
739
			return false;
740
		}
741
 
742
		if (itemId === "") {
743
			alert("please select item");
744
			return false;
745
		}
746
		if (qty === "") {
747
			alert("please choose qty");
748
			return false;
749
		}
750
 
751
		if (rate === "") {
752
			alert("Rate can't be empty");
753
			return false;
754
		}
755
 
756
	}
757
 
758
	console.log(totalQty)
759
 
760
	if (totalQty > numItems) {
761
		alert("Qty Should not be more than  Invoice items");
762
		return false;
763
	}
764
 
765
	if (validate) {
766
 
767
		if (totalQty != numItems) {
768
			alert("Qty Should not match with Invoice items");
769
			return false;
770
		}
771
	}
772
 
773
 
774
	invoiceJson['invoiceId'] = invoiceId;
775
	invoiceJson['warehouseId'] = warehouseId;
776
	invoiceJson['supplierId'] = supplierId;
777
	invoiceJson['invoiceItems'] = invoiceItems
778
	if (validate) {
779
		validateInvoiceItems(invoiceJson);
780
	} else {
781
		saveInvoiceItems(invoiceJson)
782
	}
783
}
784
 
785
 
786
function saveInvoiceItems(invoiceJson) {
787
 
788
 
789
	if (confirm("Are you sure you want to save invoice item") == true) {
790
 
791
		doPostAjaxRequestWithJsonHandler(context
792
			+ "/invoiceItemDetail", JSON
793
				.stringify(invoiceJson), function(response) {
794
					if (response == 'true') {
795
						getInvoiceItems(invoiceJson.invoiceId);
796
					}
797
				});
798
	}
799
 
800
}
801
 
802
 
803
function validateInvoiceItems(invoiceJson) {
804
 
805
 
806
	if (confirm("Are you sure you want to validate invoice item") == true) {
807
 
808
		doPostAjaxRequestWithJsonHandler(context
809
			+ "/validateInvoiceItemDetail", JSON
810
				.stringify(invoiceJson), function(response) {
811
					$('.invoiceadditemcontainer').html(response);
812
 
813
				});
814
	}
815
 
816
}
817
 
818
function getOpenPOFromWarehouse() {
819
 
820
	var warehouseId = $('#warehouseMap').val();
821
	doGetAjaxRequestHandler(context + "/getOpenPurchaseOrderByWarehouseId?warehouseId=" + warehouseId, function(response) {
822
		$('#warehouseManagePuchaseContainer').html(response);
823
	});
824
 
825
 
826
 
827
}
828
 
829
function getPurchaseLineitem(poId) {
830
 
831
 
832
	doGetAjaxRequestHandler(context + "/getPurchaseOrderItemByPoId?poId=" + poId, function(response) {
833
		$('#warehouseManagePuchaseItemContainer').html(response);
834
		$('#warehousepurchaseitemgrn').hide()
835
	});
836
 
837
 
838
}
839
 
840
 
841
function getInvoiceItems(invoiceId) {
842
 
843
	doGetAjaxRequestHandler(context + "/getInvoiceItems?invoiceId=" + invoiceId, function(response) {
844
		$('.invoiceadditemcontainer').html(response);
845
 
846
	});
847
}
848
 
849