Subversion Repositories SmartDukaan

Rev

Rev 32145 | Rev 32195 | 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
 
201
 
32192 tejbeer 202
 
32145 tejbeer 203
		getItemAheadOptions($html.find('.typeaheaditem'), true, function(
204
			selectedItem) {
205
			var itemId = selectedItem.itemId;
206
 
207
			var vendorId = $('#vendorId').val();
208
 
32192 tejbeer 209
			if (purchaseItemIds.indexOf(itemId) > -1) {
32145 tejbeer 210
				alert("item already selected");
211
				$html.find('.typeaheaditem').val("")
212
 
213
				return false;
214
			}
215
 
32192 tejbeer 216
			purchaseItemIds.push(itemId)
32145 tejbeer 217
 
218
 
219
 
220
			doGetAjaxRequestHandler(context + "/getPricing?vendorId=" + vendorId + "&itemId=" + itemId, function(response) {
221
				console.log(response)
222
				if (response != "null") {
223
					var jsonObj = JSON.parse(response);
224
 
225
					console.log(jsonObj)
226
					$html.find('.transferPrice').val(jsonObj.transferPrice)
227
 
228
					$html.find('.transferPrice').data('itemid', itemId)
229
				} else {
230
 
231
					console.log(response)
232
					$html.find('.typeaheaditem').val("")
233
 
234
				}
235
			});
236
 
237
		});
238
		$('tbody').append($html);
239
 
240
	});
241
 
242
	$(document).on('click', '.createSendPurchaseOrder', function() {
243
 
244
		createPurchase(true);
245
 
246
	});
247
 
248
 
249
	$(document).on('click', '.createPurchaseOrder', function() {
250
 
251
 
252
		createPurchase(false);
253
	});
254
 
255
 
256
	$(document).on('change', '.qty', function() {
257
 
258
 
259
		var row = $(this).closest("tr");
260
		var qty = $(row).find(".qty").val();
261
		var transferPrice = $(row).find(".transferPrice").val();
262
 
263
		var totalVal = transferPrice * qty;
264
 
265
		var totalValue = $(row).find(".totalValue").val(totalVal);
266
 
267
		var purchaseOrderValue = 0;
268
 
269
		$("table > tbody > tr").each(function() {
270
 
271
			var totalValue = $(this).find(".totalValue").val();
272
			purchaseOrderValue += totalValue
273
 
274
		});
275
 
276
	});
277
 
278
 
279
 
280
 
281
	$(document).on('click', '.warehouse-open-purchase-order', function() {
282
		loadOpenPurchase("main-content");
283
	});
284
 
285
 
286
 
287
	$(document).on('click', '.editViewPurchaseOrder', function() {
288
		var purchaseOrderId = $(this).data('poid');
289
		doGetAjaxRequestHandler(context + "/getEditPOByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
290
			$('#warehouseEditPurchaseContainer .modal-content').html(response);
291
		});
292
 
293
	});
294
 
295
	$(document).on('click', '.editPurchaseOrder', function() {
296
		var purchaseOrderId = $(this).data('poid');
297
 
298
		editPurchase(true, purchaseOrderId);
299
 
300
	});
301
 
302
 
303
	$(document).on('click', '.editSendPurchaseOrder', function() {
304
		var purchaseOrderId = $(this).data('poid');
305
 
306
 
307
		editPurchase(false, purchaseOrderId);
308
	});
309
 
310
	$(document).on('click', '.closePurchaseOrder', function() {
311
		var purchaseOrderId = $(this).data('poid');
312
		if (confirm("Are you sure you want to close the PO") == true) {
313
			doPostAjaxRequestHandler(context + "/closePuchaseOrder?purchaseId=" + purchaseOrderId,
314
				function(response) {
315
 
316
					console.log(response);
317
					if (response == 'true') {
318
						alert("successfully closed");
319
						loadOpenPurchase("main-content")
320
					}
321
				});
322
		}
323
	});
324
 
325
 
326
	$(document).on('click', '.warehouse-view-purchase-order', function() {
327
		doGetAjaxRequestHandler(context + "/viewPurchaseOrder", function(response) {
328
			$('#' + 'main-content').html(response);
329
		});
330
	});
331
 
332
 
333
 
32192 tejbeer 334
 
335
 
32145 tejbeer 336
	$(document).on('click', '.dateWisePo', function() {
337
 
338
		var startDate = getDatesFromPicker('input[name="duration"]').startDate;
339
		var endDate = getDatesFromPicker('input[name="duration"]').endDate
340
 
341
 
342
		doGetAjaxRequestHandler(context + "/getPurchaseOrders?startDate=" + startDate + "&endDate=" + endDate, function(response) {
343
			$('.purchaseorderviewcontainer').html(response);
344
 
345
		});
346
 
347
 
348
	});
349
 
350
 
351
 
352
	$(document).on('click', '.viewPurchaseOrderlineItem', function() {
353
		var purchaseOrderId = $(this).data('poid');
354
 
355
		doGetAjaxRequestHandler(context + "/getWarehouseLineItemByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
356
			$('#warehouseLineItem .modal-content').html(response);
357
 
358
		});
359
	});
360
 
361
 
362
 
32192 tejbeer 363
 
364
	$(document).on("click", '.removeInPurchaseOrder', function() {
365
 
366
		var row = $(this).closest("tr");
367
		row.remove();
368
	});
369
 
370
	$(document).on('click', ".addRowForInvoiceItem", function() {
371
 
372
		var numitems = $(this).data("numitems");
373
		var invoiceId = $(this).data("invoiceid");
374
 
375
 
376
		var invoiceItemIds = [];
377
		var totalQty = 0
378
 
379
		$("#invoice-order-table > tbody > tr").each(function() {
380
			var itemId = $(this).find(".rate").data('itemid');
381
			var qty = $(this).find(".qty").val();
382
 
383
			console.log(qty)
384
 
385
			if (qty != undefined) {
386
				totalQty += qty
387
			}
388
 
389
			console.log(totalQty)
390
 
391
 
392
			if (itemId != undefined) {
393
				invoiceItemIds.push(itemId)
394
			}
395
		});
396
 
397
		var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td>' +
398
			'<td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td>' +
399
			'<td>  <input type="number" class="form-control rate"  disable placeholder="Rate"/> </td>' +
400
			'<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td>  </tr> ');
401
 
402
 
403
		getItemAheadOptions($html.find('.typeaheaditem'), true, function(
404
			selectedItem) {
405
			var itemId = selectedItem.itemId;
406
 
407
 
408
			console.log(invoiceItemIds)
409
 
410
			if (invoiceItemIds.indexOf(itemId) > -1) {
411
				alert("item already selected");
412
				$html.find('.typeaheaditem').val("")
413
 
414
				return false;
415
			}
416
			$html.find('.rate').data('itemid', itemId)
417
 
418
			$html.find('.removeInInvoiceItem').data('invoiceid', invoiceId)
419
			$html.find('.removeInInvoiceItem').data('itemid', itemId)
420
 
421
		});
422
 
423
 
424
		if (totalQty < numitems) {
425
 
426
			$('#invoice-order-table tbody').append($html);
427
		}
428
 
429
	});
430
 
431
 
432
 
433
 
434
 
435
	$(document).on('click', '.saveInvoiceDetail', function() {
436
 
437
		var numItems = $(this).data("numitems");
438
		var invoiceId = $(this).data("invoiceid");
439
		var warehouseId = $(this).data("warehouseid");
440
		var supplierId = $(this).data("supplierid");
441
		getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, false);
442
 
443
	});
444
 
445
 
446
 
447
	$(document).on('click', '.validateInvoiceDetail', function() {
448
		var numItems = $(this).data("numitems");
449
		var invoiceId = $(this).data("invoiceid");
450
		var warehouseId = $(this).data("warehouseid");
451
		var supplierId = $(this).data("supplierid");
452
 
453
		getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, true);
454
 
455
	});
456
 
457
 
458
	$(document).on("click", '.removeInInvoiceItem', function() {
459
 
460
		var row = $(this).closest("tr");
461
		var invoiceId = $(this).data("invoiceid");
462
		var itemId = $(this).data("itemid");
463
		if (invoiceId != undefined && itemId != undefined) {
464
			doDeleteAjaxRequestHandler(context + "/removeInvoiceItem?invoiceId="
465
				+ invoiceId + "&itemId=" + itemId, function(response) {
466
					if (response == "true") {
467
						alert("Item removed successfully");
468
 
469
					}
470
				});
471
		}
472
 
473
		row.remove();
474
 
475
	});
476
 
477
 
478
	$(document).on('click', '.purchaseGrn', function() {
479
 
480
		var grnItemArray = [];
481
 
482
		var invoiceId = $(this).data("invoiceid");
483
 
484
 
485
		$("#invoice-purchase-validate > tbody > tr").each(function() {
486
			var grnItemJson = {};
487
 
488
			var itemId = $(this).find(".itemId").text();
489
			var qty = $(this).find(".qty").text();
490
			var poId = $(this).find(".purchaseId").text();
491
 
492
			var itemType = $(this).find(".itemType").text();
493
 
494
			console.log(itemType);
495
 
496
			if (itemType == "Serialized") {
497
				var serialNumbers = $(".imeis-to-grn").tagsinput('items');
498
				grnItemJson['serialNumbers'] = serialNumbers
499
 
500
			}
501
			console.log(serialNumbers)
502
			grnItemJson['itemId'] = itemId;
503
			grnItemJson['serialNumbers'] = serialNumbers
504
			grnItemJson['qty'] = qty
505
			grnItemJson['poId'] = poId
506
			grnItemJson['invoiceId'] = invoiceId
507
			grnItemArray.push(grnItemJson)
508
 
509
			console.log(grnItemArray)
510
 
511
		});
512
 
513
		for (var i = 0; i < grnItemArray.length; i++) {
514
 
515
			var serialNumbers = grnItemArray[i].serialNumbers.length
516
 
517
			if (serialNumbers > 0) {
518
 
519
				var serialNumbers = grnItemArray[i].serialNumbers.length
520
				var qty = grnItemArray[i].qty
521
 
522
				if (serialNumbers != qty) {
523
					alert("serial number is not matched with qty")
524
					return false;
525
				}
526
			}
527
 
528
		}
529
 
530
 
531
		console.log(JSON.stringify(grnItemArray))
532
		if (confirm("Are you sure you want to grn purchase order") == true) {
533
 
534
			doPostAjaxRequestWithJsonHandler(context
535
				+ "/createGrn", JSON
536
					.stringify(grnItemArray), function(response) {
537
						if (response == 'true') {
538
							alert("successfully done");
539
						}
540
					});
541
		}
542
 
543
 
544
 
545
	});
546
 
547
 
32145 tejbeer 548
});
549
 
550
function loadCreatePurchase(domId) {
551
	doGetAjaxRequestHandler(context + "/warehousePurchaseOrder", function(response) {
552
		$('#' + domId).html(response);
553
	});
554
}
555
 
32192 tejbeer 556
 
557
 
32145 tejbeer 558
function loadOpenPurchase(domId) {
559
 
560
	doGetAjaxRequestHandler(context + "/getOpenPurchaseOrder", function(response) {
561
		$('#' + domId).html(response);
562
	});
563
}
564
 
32192 tejbeer 565
function loadNewReceiveInvoice(domId) {
566
	doGetAjaxRequestHandler(context + "/newReceiveInvoice", function(response) {
567
		$('#' + domId).html(response);
568
	});
569
}
570
 
32145 tejbeer 571
function createPurchase(sendPo) {
572
	var purchaseOrder = {};
573
 
574
	var vendorId = $('#vendorId').val();
575
 
576
	var warehouseId = $('#warehouseMap').val();
577
 
578
 
579
	var items = []
580
	$("table > tbody > tr").each(function() {
581
		var purchaseOrderJson = {};
582
 
583
		var itemId = $(this).find(".transferPrice").data('itemid');
584
		var qty = $(this).find(".qty").val();
585
		var transferPrice = $(this).find(".transferPrice").val();
586
		var totalValue = $(this).find(".totalValue").val();
587
 
588
 
589
		purchaseOrderJson['itemId'] = itemId;
590
		purchaseOrderJson['qty'] = qty
591
		purchaseOrderJson['totalValue'] = totalValue
592
		purchaseOrderJson['transferPrice'] = transferPrice
593
 
594
		items.push(purchaseOrderJson)
595
	});
596
 
597
 
598
	for (var i = 0; i < items.length; i++) {
599
		console.log(items[i])
600
 
601
		var itemId = items[i].itemId
602
		var qty = items[i].qty
603
		var transferPrice = items[i].transferPrice
604
		var totalValue = items[i].totalValue
605
 
606
		if (itemId === "" && qty === "" && transferPrice === "" && totalValue === "") {
607
			alert("Field can't be empty");
608
			return false;
609
		}
610
 
611
 
612
		if (itemId === "") {
613
			alert("please select item");
614
			return false;
615
		}
616
		if (qty === "") {
617
			alert("please choose qty");
618
			return false;
619
		}
620
 
621
		if (transferPrice === "") {
622
			alert("Transfer Price can't be empty");
623
			return false;
624
		}
625
		if (totalValue === "") {
626
			alert("Total value can't be empty");
627
			return false;
628
		}
629
 
630
 
631
 
632
	}
633
 
634
	purchaseOrder['vendorId'] = vendorId;
635
	purchaseOrder['warehouseId'] = warehouseId
636
	purchaseOrder['sendPo'] = sendPo
637
 
638
	purchaseOrder['items'] = items
639
 
640
	console.log(purchaseOrder)
641
 
642
 
643
 
644
	if (confirm("Are you sure you want to create purchase order") == true) {
645
 
646
		doPostAjaxRequestWithJsonHandler(context
647
			+ "/createPurchaseOrder", JSON
648
				.stringify(purchaseOrder), function(response) {
649
					if (response == 'true') {
650
						alert("successfully created");
651
					}
652
				});
653
	}
654
 
655
}
656
 
657
 
658
function editPurchase(sendPo, poid) {
659
	var editpurchaseOrder = {}
660
	var items = []
661
	$("#purchase-edit-lineitem > tbody > tr").each(function() {
662
		var purchaseOrderJson = {};
663
		var itemId = $(this).find("td:eq(0)").text();
664
 
665
		var qty = $(this).find(".editqty").val();
666
 
667
		purchaseOrderJson['itemId'] = itemId;
668
		purchaseOrderJson['qty'] = qty
669
 
670
		items.push(purchaseOrderJson)
671
	});
672
 
673
 
674
	for (var i = 0; i < items.length; i++) {
675
		console.log(items[i])
676
 
677
		var qty = items[i].qty
678
 
679
		if (qty === "") {
680
			alert("please choose qty");
681
			return false;
682
		}
683
 
684
		if (qty < 0) {
685
			alert("Quantity should be greater than 0");
686
			return false;
687
		}
688
 
689
 
690
	}
691
 
692
	editpurchaseOrder['purchaseOrderId'] = poid;
693
	editpurchaseOrder['sendPo'] = sendPo
694
	editpurchaseOrder['items'] = items
695
 
696
 
697
	if (confirm("Are you sure you want to edit purchase order") == true) {
698
 
699
		doPostAjaxRequestWithJsonHandler(context
700
			+ "/editPurchaseOrder", JSON
701
				.stringify(editpurchaseOrder), function(response) {
702
					if (response == 'true') {
703
						alert("successfully created");
704
					}
705
				});
706
	}
707
 
708
}
709
 
710
 
32192 tejbeer 711
function getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, validate) {
712
 
713
	var invoiceJson = {};
714
	console.log(numItems)
715
	var totalQty = 0;
716
	var invoiceItems = []
717
	$("#invoice-order-table > tbody > tr").each(function() {
718
		var invoiceItemJson = {};
719
		var itemId = $(this).find(".rate").data('itemid');
720
		var qty = $(this).find(".qty").val();
721
 
722
		if (qty != undefined) {
723
			totalQty += parseInt(qty)
724
		}
725
		var rate = $(this).find(".rate").val();
726
		invoiceItemJson['itemId'] = itemId;
727
		invoiceItemJson['qty'] = qty
728
		invoiceItemJson['rate'] = rate
729
		invoiceItems.push(invoiceItemJson)
730
	});
731
 
732
 
733
	for (var i = 0; i < invoiceItems.length; i++) {
734
 
735
		var itemId = invoiceItems[i].itemId
736
		var qty = invoiceItems[i].qty
737
		var rate = invoiceItems[i].rate
738
		if (itemId === "" && qty === "" && rate === "") {
739
			alert("Field can't be empty");
740
			return false;
741
		}
742
 
743
		if (itemId === "") {
744
			alert("please select item");
745
			return false;
746
		}
747
		if (qty === "") {
748
			alert("please choose qty");
749
			return false;
750
		}
751
 
752
		if (rate === "") {
753
			alert("Rate can't be empty");
754
			return false;
755
		}
756
 
757
	}
758
 
759
	console.log(totalQty)
760
 
761
	if (totalQty > numItems) {
762
		alert("Qty Should not be more than  Invoice items");
763
		return false;
764
	}
765
 
766
	if (validate) {
767
 
768
		if (totalQty != numItems) {
769
			alert("Qty Should not match with Invoice items");
770
			return false;
771
		}
772
	}
773
 
774
 
775
	invoiceJson['invoiceId'] = invoiceId;
776
	invoiceJson['warehouseId'] = warehouseId;
777
	invoiceJson['supplierId'] = supplierId;
778
	invoiceJson['invoiceItems'] = invoiceItems
779
	if (validate) {
780
		validateInvoiceItems(invoiceJson);
781
	} else {
782
		saveInvoiceItems(invoiceJson)
783
	}
784
}
785
 
786
 
787
function saveInvoiceItems(invoiceJson) {
788
 
789
 
790
	if (confirm("Are you sure you want to save invoice item") == true) {
791
 
792
		doPostAjaxRequestWithJsonHandler(context
793
			+ "/invoiceItemDetail", JSON
794
				.stringify(invoiceJson), function(response) {
795
					if (response == 'true') {
796
						getInvoiceItems(invoiceJson.invoiceId);
797
					}
798
				});
799
	}
800
 
801
}
802
 
803
 
804
function validateInvoiceItems(invoiceJson) {
805
 
806
 
807
	if (confirm("Are you sure you want to validate invoice item") == true) {
808
 
809
		doPostAjaxRequestWithJsonHandler(context
810
			+ "/validateInvoiceItemDetail", JSON
811
				.stringify(invoiceJson), function(response) {
812
					$('.invoiceadditemcontainer').html(response);
813
 
814
				});
815
	}
816
 
817
}
818
 
819
function getOpenPOFromWarehouse() {
820
 
821
	var warehouseId = $('#warehouseMap').val();
822
	doGetAjaxRequestHandler(context + "/getOpenPurchaseOrderByWarehouseId?warehouseId=" + warehouseId, function(response) {
823
		$('#warehouseManagePuchaseContainer').html(response);
824
	});
825
 
826
 
827
 
828
}
829
 
830
function getPurchaseLineitem(poId) {
831
 
832
 
833
	doGetAjaxRequestHandler(context + "/getPurchaseOrderItemByPoId?poId=" + poId, function(response) {
834
		$('#warehouseManagePuchaseItemContainer').html(response);
835
		$('#warehousepurchaseitemgrn').hide()
836
	});
837
 
838
 
839
}
840
 
841
 
842
function getInvoiceItems(invoiceId) {
843
 
844
	doGetAjaxRequestHandler(context + "/getInvoiceItems?invoiceId=" + invoiceId, function(response) {
845
		$('.invoiceadditemcontainer').html(response);
846
 
847
	});
848
}
849
 
850