| 32145 |
tejbeer |
1 |
$(function() {
|
|
|
2 |
$(document).on('click', ".warehouse-create-purchase-order", function() {
|
|
|
3 |
loadCreatePurchase("main-content");
|
|
|
4 |
});
|
|
|
5 |
|
| 32192 |
tejbeer |
6 |
$(document).on('click', ".warehouse-receive-new-invoice", function() {
|
|
|
7 |
loadNewReceiveInvoice("main-content");
|
|
|
8 |
});
|
| 32145 |
tejbeer |
9 |
|
| 32192 |
tejbeer |
10 |
|
| 32256 |
tejbeer |
11 |
$(document).on('click', ".warehouse-grn-request", function() {
|
|
|
12 |
loadGrnRequest("main-content");
|
|
|
13 |
});
|
| 32192 |
tejbeer |
14 |
|
| 32300 |
tejbeer |
15 |
|
| 32256 |
tejbeer |
16 |
$(document).on('click', ".warehouse-debit-note", function() {
|
|
|
17 |
loadDebitNote("main-content");
|
|
|
18 |
});
|
| 32192 |
tejbeer |
19 |
|
|
|
20 |
|
| 32256 |
tejbeer |
21 |
|
| 32300 |
tejbeer |
22 |
$(document).on('click', ".warehouse-invoices", function() {
|
|
|
23 |
loadWarehouseInvoices("main-content");
|
|
|
24 |
});
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
$(document).on('click', '.dateWiseInvoices', function() {
|
|
|
28 |
|
|
|
29 |
var startDate = getDatesFromPicker('input[name="invoice-duration"]').startDate;
|
|
|
30 |
var endDate = getDatesFromPicker('input[name="invoice-duration"]').endDate
|
|
|
31 |
|
|
|
32 |
var vendorId = $('#vendorId').val();
|
|
|
33 |
|
|
|
34 |
doGetAjaxRequestHandler(context + "/getWarehouseInvoicesByVendor?vendorId=" + vendorId + "&startDate=" + startDate + "&endDate=" + endDate, function(response) {
|
|
|
35 |
$('.invoicesviewcontainer').html(response);
|
|
|
36 |
|
|
|
37 |
});
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
});
|
|
|
41 |
|
|
|
42 |
|
| 32192 |
tejbeer |
43 |
$(document)
|
|
|
44 |
.on(
|
|
|
45 |
'input',
|
|
|
46 |
'#invoice',
|
|
|
47 |
function() {
|
|
|
48 |
if (confirm('Document has been selected, Do you want to upload ?')) {
|
|
|
49 |
var fileSelector = $('#invoice')[0];
|
|
|
50 |
if (fileSelector != undefined
|
|
|
51 |
&& fileSelector.files[0] != undefined) {
|
|
|
52 |
var url = context + '/document-upload';
|
|
|
53 |
|
|
|
54 |
console.log(url);
|
|
|
55 |
var file = this.files[0];
|
|
|
56 |
doAjaxUploadRequestHandler(
|
|
|
57 |
url,
|
|
|
58 |
'POST',
|
|
|
59 |
file,
|
|
|
60 |
function(response) {
|
|
|
61 |
console.log(response);
|
|
|
62 |
var documentId = response.response.document_id;
|
|
|
63 |
console.log("documentId : "
|
|
|
64 |
+ documentId);
|
| 32296 |
tejbeer |
65 |
localStorage.setItem("invoiceDocument",
|
|
|
66 |
documentId);
|
| 32295 |
tejbeer |
67 |
|
| 32300 |
tejbeer |
68 |
|
| 32192 |
tejbeer |
69 |
});
|
|
|
70 |
|
|
|
71 |
}
|
|
|
72 |
} else {
|
|
|
73 |
// Do nothing!
|
|
|
74 |
}
|
|
|
75 |
});
|
|
|
76 |
|
|
|
77 |
$(document).on('click', ".createReceiveInvoice", function() {
|
|
|
78 |
|
|
|
79 |
var invoiceDate = $('#actualDate').val();
|
|
|
80 |
|
|
|
81 |
var warehouseId = $('#warehouseMap').val();
|
|
|
82 |
|
|
|
83 |
var numItems = $('#numberofItems').val();
|
|
|
84 |
|
|
|
85 |
var supplierId = $('#vendorId').val();
|
|
|
86 |
|
|
|
87 |
var totalValue = $('#totalValue').val();
|
|
|
88 |
|
|
|
89 |
var invoiceNumber = $('#invoiceNumber').val();
|
|
|
90 |
|
|
|
91 |
|
| 32296 |
tejbeer |
92 |
var invoiceDoc = localStorage
|
|
|
93 |
.getItem("invoiceDocument");
|
| 32192 |
tejbeer |
94 |
|
|
|
95 |
|
|
|
96 |
console.log(invoiceDoc)
|
|
|
97 |
|
|
|
98 |
|
| 32311 |
tejbeer |
99 |
if (invoiceDate === "" && warehouseId === "" && numItems === "" && supplierId === "" && totalValue === "" && invoiceNumber === "" && invoiceDoc === "") {
|
| 32192 |
tejbeer |
100 |
alert("Field can't be empty");
|
|
|
101 |
return false;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
if (invoiceDate === "") {
|
|
|
106 |
alert("please select date");
|
|
|
107 |
return false;
|
|
|
108 |
}
|
|
|
109 |
if (warehouseId === "") {
|
|
|
110 |
alert("please choose warehouse");
|
|
|
111 |
return false;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
if (numItems === "") {
|
|
|
115 |
alert("please fill number of items.");
|
|
|
116 |
return false;
|
|
|
117 |
}
|
|
|
118 |
|
| 32311 |
tejbeer |
119 |
|
| 32192 |
tejbeer |
120 |
if (supplierId === "") {
|
|
|
121 |
alert("please choose supplier");
|
|
|
122 |
return false;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
if (totalValue === "") {
|
|
|
128 |
alert("please fill Total Value.");
|
|
|
129 |
return false;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
if (invoiceNumber === "") {
|
|
|
133 |
alert("please fill Invoice Number.");
|
|
|
134 |
return false;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
if (invoiceDoc === "") {
|
|
|
139 |
alert("please upload invoice.");
|
|
|
140 |
return false;
|
|
|
141 |
}
|
|
|
142 |
var newReceiveInvoice = {};
|
|
|
143 |
|
|
|
144 |
newReceiveInvoice['invoiceDate'] = invoiceDate;
|
|
|
145 |
newReceiveInvoice['warehouseId'] = warehouseId
|
|
|
146 |
newReceiveInvoice['numItems'] = numItems
|
|
|
147 |
newReceiveInvoice['supplierId'] = supplierId
|
|
|
148 |
newReceiveInvoice['totalValue'] = totalValue
|
|
|
149 |
newReceiveInvoice['invoiceNumber'] = invoiceNumber
|
|
|
150 |
newReceiveInvoice['invoiceDoc'] = invoiceDoc
|
|
|
151 |
|
| 32295 |
tejbeer |
152 |
console.log()
|
|
|
153 |
|
| 32192 |
tejbeer |
154 |
if (confirm("Are you sure you want to add new Invoice") == true) {
|
|
|
155 |
|
|
|
156 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
157 |
+ "/newReceiveInvoice", JSON
|
|
|
158 |
.stringify(newReceiveInvoice), function(response) {
|
|
|
159 |
if (response == 'true') {
|
|
|
160 |
alert("successfully added");
|
| 32296 |
tejbeer |
161 |
localStorage.removeItem("invoiceDocument");
|
| 32192 |
tejbeer |
162 |
loadNewReceiveInvoice("main-content");
|
|
|
163 |
}
|
|
|
164 |
});
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
});
|
|
|
172 |
|
|
|
173 |
|
| 32325 |
amit.gupta |
174 |
var purchaseItemIds;
|
| 32145 |
tejbeer |
175 |
$(document).on('click', ".purchaseorderitemview", function() {
|
| 32325 |
amit.gupta |
176 |
purchaseItemIds = [];
|
| 32145 |
tejbeer |
177 |
var vendorId = $('#vendorId').val();
|
|
|
178 |
var warehouseId = $('#warehouseMap').val();
|
|
|
179 |
|
|
|
180 |
console.log(warehouseId)
|
|
|
181 |
|
|
|
182 |
if (warehouseId == null && vendorId === "") {
|
|
|
183 |
alert("Field can't be empty");
|
|
|
184 |
return;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
if (warehouseId == null) {
|
|
|
189 |
alert("please select warehouse");
|
|
|
190 |
return;
|
|
|
191 |
}
|
|
|
192 |
if (vendorId === "") {
|
|
|
193 |
alert("please select vendor");
|
|
|
194 |
return;
|
|
|
195 |
}
|
|
|
196 |
doGetAjaxRequestHandler(context + "/addPurchaseItemView?warehouseId=" + warehouseId + "&vendorId=" + vendorId, function(response) {
|
|
|
197 |
$(".createpurchaseordercontainer").html(response);
|
|
|
198 |
});
|
|
|
199 |
});
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
$(document).on('click', ".addRowInPurchaseOrder", function() {
|
| 32192 |
tejbeer |
203 |
var totalQty = 0
|
|
|
204 |
|
|
|
205 |
$("table > tbody > tr").each(function() {
|
|
|
206 |
var itemId = $(this).find(".transferPrice").data('itemid');
|
|
|
207 |
var qty = $(this).find(".qty").val();
|
|
|
208 |
|
|
|
209 |
console.log(qty)
|
|
|
210 |
|
|
|
211 |
if (qty != undefined) {
|
|
|
212 |
totalQty += parseInt(qty)
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
console.log(totalQty)
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
if (itemId != undefined) {
|
|
|
219 |
purchaseItemIds.push(itemId)
|
|
|
220 |
}
|
|
|
221 |
});
|
|
|
222 |
|
| 32145 |
tejbeer |
223 |
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> ');
|
|
|
224 |
|
| 32195 |
tejbeer |
225 |
var vendorId = $('#vendorId').val();
|
| 32145 |
tejbeer |
226 |
|
| 32325 |
amit.gupta |
227 |
$('tbody').append($html);
|
| 32195 |
tejbeer |
228 |
getVendorItemAheadOptions($html.find('.typeaheaditem'), vendorId, function(
|
| 32145 |
tejbeer |
229 |
selectedItem) {
|
|
|
230 |
var itemId = selectedItem.itemId;
|
|
|
231 |
|
| 32192 |
tejbeer |
232 |
if (purchaseItemIds.indexOf(itemId) > -1) {
|
| 32145 |
tejbeer |
233 |
alert("item already selected");
|
|
|
234 |
$html.find('.typeaheaditem').val("")
|
|
|
235 |
|
|
|
236 |
return false;
|
|
|
237 |
}
|
|
|
238 |
|
| 32349 |
amit.gupta |
239 |
purchaseItemIds.push(itemId);
|
| 32145 |
tejbeer |
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
doGetAjaxRequestHandler(context + "/getPricing?vendorId=" + vendorId + "&itemId=" + itemId, function(response) {
|
|
|
244 |
console.log(response)
|
|
|
245 |
if (response != "null") {
|
|
|
246 |
var jsonObj = JSON.parse(response);
|
|
|
247 |
|
|
|
248 |
console.log(jsonObj)
|
|
|
249 |
$html.find('.transferPrice').val(jsonObj.transferPrice)
|
|
|
250 |
|
|
|
251 |
$html.find('.transferPrice').data('itemid', itemId)
|
|
|
252 |
} else {
|
|
|
253 |
|
|
|
254 |
console.log(response)
|
|
|
255 |
$html.find('.typeaheaditem').val("")
|
|
|
256 |
|
|
|
257 |
}
|
|
|
258 |
});
|
|
|
259 |
|
|
|
260 |
});
|
|
|
261 |
|
|
|
262 |
});
|
|
|
263 |
|
|
|
264 |
$(document).on('click', '.createSendPurchaseOrder', function() {
|
|
|
265 |
|
|
|
266 |
createPurchase(true);
|
|
|
267 |
|
|
|
268 |
});
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
$(document).on('click', '.createPurchaseOrder', function() {
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
createPurchase(false);
|
|
|
275 |
});
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
$(document).on('change', '.qty', function() {
|
|
|
279 |
|
|
|
280 |
|
|
|
281 |
var row = $(this).closest("tr");
|
|
|
282 |
var qty = $(row).find(".qty").val();
|
|
|
283 |
var transferPrice = $(row).find(".transferPrice").val();
|
|
|
284 |
|
|
|
285 |
var totalVal = transferPrice * qty;
|
|
|
286 |
|
|
|
287 |
var totalValue = $(row).find(".totalValue").val(totalVal);
|
|
|
288 |
|
|
|
289 |
var purchaseOrderValue = 0;
|
|
|
290 |
|
|
|
291 |
$("table > tbody > tr").each(function() {
|
|
|
292 |
|
|
|
293 |
var totalValue = $(this).find(".totalValue").val();
|
|
|
294 |
purchaseOrderValue += totalValue
|
|
|
295 |
|
|
|
296 |
});
|
|
|
297 |
|
|
|
298 |
});
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
$(document).on('click', '.warehouse-open-purchase-order', function() {
|
|
|
304 |
loadOpenPurchase("main-content");
|
|
|
305 |
});
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
|
309 |
$(document).on('click', '.editViewPurchaseOrder', function() {
|
|
|
310 |
var purchaseOrderId = $(this).data('poid');
|
|
|
311 |
doGetAjaxRequestHandler(context + "/getEditPOByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
|
|
|
312 |
$('#warehouseEditPurchaseContainer .modal-content').html(response);
|
|
|
313 |
});
|
|
|
314 |
|
|
|
315 |
});
|
|
|
316 |
|
|
|
317 |
$(document).on('click', '.editPurchaseOrder', function() {
|
|
|
318 |
var purchaseOrderId = $(this).data('poid');
|
|
|
319 |
|
| 32256 |
tejbeer |
320 |
editPurchase(false, purchaseOrderId);
|
| 32145 |
tejbeer |
321 |
|
|
|
322 |
});
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
$(document).on('click', '.editSendPurchaseOrder', function() {
|
|
|
326 |
var purchaseOrderId = $(this).data('poid');
|
|
|
327 |
|
|
|
328 |
|
| 32256 |
tejbeer |
329 |
editPurchase(true, purchaseOrderId);
|
| 32145 |
tejbeer |
330 |
});
|
|
|
331 |
|
|
|
332 |
$(document).on('click', '.closePurchaseOrder', function() {
|
|
|
333 |
var purchaseOrderId = $(this).data('poid');
|
|
|
334 |
if (confirm("Are you sure you want to close the PO") == true) {
|
|
|
335 |
doPostAjaxRequestHandler(context + "/closePuchaseOrder?purchaseId=" + purchaseOrderId,
|
|
|
336 |
function(response) {
|
|
|
337 |
|
|
|
338 |
console.log(response);
|
|
|
339 |
if (response == 'true') {
|
|
|
340 |
alert("successfully closed");
|
|
|
341 |
loadOpenPurchase("main-content")
|
|
|
342 |
}
|
|
|
343 |
});
|
|
|
344 |
}
|
|
|
345 |
});
|
|
|
346 |
|
|
|
347 |
|
|
|
348 |
$(document).on('click', '.warehouse-view-purchase-order', function() {
|
|
|
349 |
doGetAjaxRequestHandler(context + "/viewPurchaseOrder", function(response) {
|
|
|
350 |
$('#' + 'main-content').html(response);
|
|
|
351 |
});
|
|
|
352 |
});
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
|
| 32192 |
tejbeer |
356 |
|
|
|
357 |
|
| 32145 |
tejbeer |
358 |
$(document).on('click', '.dateWisePo', function() {
|
|
|
359 |
|
|
|
360 |
var startDate = getDatesFromPicker('input[name="duration"]').startDate;
|
|
|
361 |
var endDate = getDatesFromPicker('input[name="duration"]').endDate
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
doGetAjaxRequestHandler(context + "/getPurchaseOrders?startDate=" + startDate + "&endDate=" + endDate, function(response) {
|
|
|
365 |
$('.purchaseorderviewcontainer').html(response);
|
|
|
366 |
|
|
|
367 |
});
|
|
|
368 |
|
|
|
369 |
|
|
|
370 |
});
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
$(document).on('click', '.viewPurchaseOrderlineItem', function() {
|
|
|
375 |
var purchaseOrderId = $(this).data('poid');
|
|
|
376 |
|
|
|
377 |
doGetAjaxRequestHandler(context + "/getWarehouseLineItemByPurchaseId?purchaseId=" + purchaseOrderId, function(response) {
|
|
|
378 |
$('#warehouseLineItem .modal-content').html(response);
|
|
|
379 |
|
|
|
380 |
});
|
|
|
381 |
});
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
|
| 32192 |
tejbeer |
385 |
|
|
|
386 |
$(document).on("click", '.removeInPurchaseOrder', function() {
|
|
|
387 |
|
|
|
388 |
var row = $(this).closest("tr");
|
| 32325 |
amit.gupta |
389 |
let itemIndex = purchaseItemIds.indexOf();
|
|
|
390 |
if (itemIndex > -1) { // only splice array when item is found
|
|
|
391 |
purchaseItemIds.splice(itemIndex, 1); // 2nd parameter means remove one item only
|
|
|
392 |
}
|
| 32192 |
tejbeer |
393 |
row.remove();
|
|
|
394 |
});
|
|
|
395 |
|
| 32256 |
tejbeer |
396 |
|
| 32192 |
tejbeer |
397 |
$(document).on('click', ".addRowForInvoiceItem", function() {
|
|
|
398 |
|
|
|
399 |
var numitems = $(this).data("numitems");
|
|
|
400 |
var invoiceId = $(this).data("invoiceid");
|
|
|
401 |
var invoiceItemIds = [];
|
|
|
402 |
var totalQty = 0
|
|
|
403 |
|
|
|
404 |
$("#invoice-order-table > tbody > tr").each(function() {
|
|
|
405 |
var itemId = $(this).find(".rate").data('itemid');
|
|
|
406 |
var qty = $(this).find(".qty").val();
|
|
|
407 |
|
|
|
408 |
if (qty != undefined) {
|
|
|
409 |
totalQty += qty
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
if (itemId != undefined) {
|
|
|
413 |
invoiceItemIds.push(itemId)
|
|
|
414 |
}
|
|
|
415 |
});
|
|
|
416 |
|
|
|
417 |
var $html = $('<tr> <td> <input type="text" class="form-control typeaheaditem" autocomplete="off" placeholder="Search Model"/> </td>' +
|
|
|
418 |
'<td> <input type="number" class="form-control qty" name = "qty" placeholder="Quantity"/> </td>' +
|
|
|
419 |
'<td> <input type="number" class="form-control rate" disable placeholder="Rate"/> </td>' +
|
|
|
420 |
'<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td> </tr> ');
|
|
|
421 |
|
|
|
422 |
|
|
|
423 |
getItemAheadOptions($html.find('.typeaheaditem'), true, function(
|
|
|
424 |
selectedItem) {
|
|
|
425 |
var itemId = selectedItem.itemId;
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
console.log(invoiceItemIds)
|
|
|
429 |
|
|
|
430 |
if (invoiceItemIds.indexOf(itemId) > -1) {
|
| 32349 |
amit.gupta |
431 |
alert("Item already added");
|
| 32192 |
tejbeer |
432 |
$html.find('.typeaheaditem').val("")
|
|
|
433 |
|
|
|
434 |
return false;
|
|
|
435 |
}
|
|
|
436 |
$html.find('.rate').data('itemid', itemId)
|
|
|
437 |
|
|
|
438 |
$html.find('.removeInInvoiceItem').data('invoiceid', invoiceId)
|
|
|
439 |
$html.find('.removeInInvoiceItem').data('itemid', itemId)
|
|
|
440 |
|
|
|
441 |
});
|
|
|
442 |
|
|
|
443 |
|
|
|
444 |
if (totalQty < numitems) {
|
|
|
445 |
|
|
|
446 |
$('#invoice-order-table tbody').append($html);
|
|
|
447 |
}
|
|
|
448 |
|
|
|
449 |
});
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
$(document).on('click', '.saveInvoiceDetail', function() {
|
|
|
456 |
|
|
|
457 |
var numItems = $(this).data("numitems");
|
|
|
458 |
var invoiceId = $(this).data("invoiceid");
|
|
|
459 |
var warehouseId = $(this).data("warehouseid");
|
|
|
460 |
var supplierId = $(this).data("supplierid");
|
|
|
461 |
getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, false);
|
|
|
462 |
|
|
|
463 |
});
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
|
467 |
$(document).on('click', '.validateInvoiceDetail', function() {
|
|
|
468 |
var numItems = $(this).data("numitems");
|
|
|
469 |
var invoiceId = $(this).data("invoiceid");
|
|
|
470 |
var warehouseId = $(this).data("warehouseid");
|
|
|
471 |
var supplierId = $(this).data("supplierid");
|
|
|
472 |
|
|
|
473 |
getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, true);
|
|
|
474 |
|
|
|
475 |
});
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
$(document).on("click", '.removeInInvoiceItem', function() {
|
|
|
479 |
|
|
|
480 |
var row = $(this).closest("tr");
|
|
|
481 |
var invoiceId = $(this).data("invoiceid");
|
|
|
482 |
var itemId = $(this).data("itemid");
|
|
|
483 |
if (invoiceId != undefined && itemId != undefined) {
|
|
|
484 |
doDeleteAjaxRequestHandler(context + "/removeInvoiceItem?invoiceId="
|
|
|
485 |
+ invoiceId + "&itemId=" + itemId, function(response) {
|
|
|
486 |
if (response == "true") {
|
|
|
487 |
alert("Item removed successfully");
|
|
|
488 |
|
|
|
489 |
}
|
|
|
490 |
});
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
row.remove();
|
|
|
494 |
|
|
|
495 |
});
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
$(document).on('click', '.purchaseGrn', function() {
|
|
|
499 |
|
|
|
500 |
var grnItemArray = [];
|
|
|
501 |
|
|
|
502 |
var invoiceId = $(this).data("invoiceid");
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
$("#invoice-purchase-validate > tbody > tr").each(function() {
|
|
|
506 |
var grnItemJson = {};
|
|
|
507 |
|
|
|
508 |
var itemId = $(this).find(".itemId").text();
|
|
|
509 |
var qty = $(this).find(".qty").text();
|
|
|
510 |
var poId = $(this).find(".purchaseId").text();
|
| 32256 |
tejbeer |
511 |
var excessQty = $(this).find(".excessQty").text();
|
| 32192 |
tejbeer |
512 |
var itemType = $(this).find(".itemType").text();
|
|
|
513 |
|
|
|
514 |
console.log(itemType);
|
|
|
515 |
|
|
|
516 |
if (itemType == "Serialized") {
|
| 32256 |
tejbeer |
517 |
var serialNumbers = $(this).find(".imeis-to-grn").tagsinput('items');
|
| 32192 |
tejbeer |
518 |
grnItemJson['serialNumbers'] = serialNumbers
|
|
|
519 |
|
| 32256 |
tejbeer |
520 |
if (excessQty > 0) {
|
|
|
521 |
var returnSerialNumbers = $(this).find(".imeis-to-grn-return").tagsinput('items');
|
|
|
522 |
grnItemJson['returnSerialNumbers'] = returnSerialNumbers
|
|
|
523 |
}
|
| 32192 |
tejbeer |
524 |
}
|
|
|
525 |
console.log(serialNumbers)
|
|
|
526 |
grnItemJson['itemId'] = itemId;
|
|
|
527 |
grnItemJson['serialNumbers'] = serialNumbers
|
|
|
528 |
grnItemJson['qty'] = qty
|
|
|
529 |
grnItemJson['poId'] = poId
|
|
|
530 |
grnItemJson['invoiceId'] = invoiceId
|
| 32256 |
tejbeer |
531 |
grnItemJson['itemType'] = itemType
|
|
|
532 |
grnItemJson['excessQty'] = excessQty
|
|
|
533 |
|
|
|
534 |
grnItemJson['returnSerialNumbers'] = returnSerialNumbers
|
|
|
535 |
|
| 32192 |
tejbeer |
536 |
grnItemArray.push(grnItemJson)
|
|
|
537 |
|
|
|
538 |
console.log(grnItemArray)
|
|
|
539 |
|
|
|
540 |
});
|
|
|
541 |
|
|
|
542 |
for (var i = 0; i < grnItemArray.length; i++) {
|
|
|
543 |
|
|
|
544 |
var serialNumbers = grnItemArray[i].serialNumbers.length
|
|
|
545 |
|
| 32256 |
tejbeer |
546 |
var itemType = grnItemArray[i].itemType
|
| 32192 |
tejbeer |
547 |
|
| 32256 |
tejbeer |
548 |
|
|
|
549 |
if (itemType == "Serialized") {
|
|
|
550 |
var excessQty = grnItemArray[i].excessQty
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
|
| 32192 |
tejbeer |
554 |
var serialNumbers = grnItemArray[i].serialNumbers.length
|
|
|
555 |
var qty = grnItemArray[i].qty
|
|
|
556 |
|
|
|
557 |
if (serialNumbers != qty) {
|
|
|
558 |
alert("serial number is not matched with qty")
|
|
|
559 |
return false;
|
|
|
560 |
}
|
| 32256 |
tejbeer |
561 |
|
|
|
562 |
if (excessQty > 0) {
|
|
|
563 |
|
|
|
564 |
var returnSerialNumbers = grnItemArray[i].returnSerialNumbers.length
|
|
|
565 |
|
|
|
566 |
if (returnSerialNumbers != excessQty) {
|
|
|
567 |
alert("Return serial number is not matched with excess qty")
|
|
|
568 |
return false;
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
}
|
| 32192 |
tejbeer |
572 |
}
|
|
|
573 |
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
|
|
|
577 |
console.log(JSON.stringify(grnItemArray))
|
|
|
578 |
if (confirm("Are you sure you want to grn purchase order") == true) {
|
|
|
579 |
|
|
|
580 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
581 |
+ "/createGrn", JSON
|
|
|
582 |
.stringify(grnItemArray), function(response) {
|
|
|
583 |
if (response == 'true') {
|
| 32258 |
tejbeer |
584 |
alert("successfully done");
|
|
|
585 |
loadNewReceiveInvoice("main-content");
|
| 32256 |
tejbeer |
586 |
}
|
|
|
587 |
});
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
});
|
|
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
$(document).on('click', '.grnRequest', function() {
|
|
|
597 |
|
|
|
598 |
var grnRequestJson = {};
|
|
|
599 |
var grnRequestItemArray = [];
|
|
|
600 |
|
|
|
601 |
var invoiceId = $(this).data("invoiceid");
|
|
|
602 |
|
|
|
603 |
|
|
|
604 |
$("#invoice-purchase-validate > tbody > tr").each(function() {
|
|
|
605 |
var grnItemJson = {};
|
|
|
606 |
|
|
|
607 |
var itemId = $.trim($(this).find(".itemId").text());
|
|
|
608 |
var poId = $.trim($(this).find(".purchaseId").text());
|
|
|
609 |
|
|
|
610 |
var qty = parseInt($(this).find(".qty").text());
|
|
|
611 |
|
|
|
612 |
var excessQty = parseInt($(this).find(".excessQty").text());
|
|
|
613 |
|
|
|
614 |
var priceMismatch = $.trim($(this).find(".priceMismatch").text());
|
|
|
615 |
console.log(priceMismatch)
|
|
|
616 |
|
|
|
617 |
|
|
|
618 |
if (priceMismatch != null || excessQty > 0) {
|
|
|
619 |
console.log(typeof priceMismatch)
|
|
|
620 |
console.log(excessQty)
|
|
|
621 |
grnItemJson['itemId'] = itemId;
|
|
|
622 |
grnItemJson['qty'] = qty;
|
|
|
623 |
grnItemJson['excessQty'] = excessQty
|
| 32264 |
tejbeer |
624 |
grnItemJson['mismatch'] = priceMismatch
|
| 32256 |
tejbeer |
625 |
grnItemJson['poId'] = poId
|
|
|
626 |
|
|
|
627 |
grnRequestItemArray.push(grnItemJson)
|
|
|
628 |
}
|
|
|
629 |
});
|
|
|
630 |
|
|
|
631 |
console.log(grnRequestItemArray)
|
|
|
632 |
|
|
|
633 |
|
|
|
634 |
|
|
|
635 |
grnRequestJson['invoiceId'] = invoiceId;
|
|
|
636 |
grnRequestJson['warehousePurchaseModel'] = grnRequestItemArray
|
|
|
637 |
|
|
|
638 |
if (confirm("Are you sure you want to raise grn request") == true) {
|
|
|
639 |
|
|
|
640 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
641 |
+ "/grnRequest", JSON
|
|
|
642 |
.stringify(grnRequestJson), function(response) {
|
|
|
643 |
if (response == 'true') {
|
| 32192 |
tejbeer |
644 |
alert("successfully done");
|
| 32256 |
tejbeer |
645 |
loadNewReceiveInvoice("main-content");
|
| 32192 |
tejbeer |
646 |
}
|
|
|
647 |
});
|
|
|
648 |
}
|
|
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
|
652 |
});
|
|
|
653 |
|
|
|
654 |
|
| 32256 |
tejbeer |
655 |
$(document).on('click', '.resolvedPriceMismatchRequest', function() {
|
|
|
656 |
var id = $(this).data("id");
|
|
|
657 |
|
|
|
658 |
var invoiceId = $(this).data("invoiceid");
|
|
|
659 |
|
|
|
660 |
var requestId = $(this).data("requestid");
|
|
|
661 |
|
| 32261 |
tejbeer |
662 |
var mismatch = $(this).data("mismatch");
|
| 32256 |
tejbeer |
663 |
|
| 32261 |
tejbeer |
664 |
if (mismatch == "InvoiceMismatch") {
|
| 32256 |
tejbeer |
665 |
if (confirm("Are you sure you want to resolve invoice mismatch") == true) {
|
|
|
666 |
|
|
|
667 |
doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id, function(response) {
|
|
|
668 |
if (response == 'true') {
|
|
|
669 |
getGrnRequestItems(requestId, invoiceId)
|
|
|
670 |
}
|
|
|
671 |
});
|
|
|
672 |
|
|
|
673 |
}
|
| 32261 |
tejbeer |
674 |
} else if (mismatch == "PoMismatch") {
|
| 32256 |
tejbeer |
675 |
if (confirm("Are you sure you want to resolve Po Mismatch. Discard the current PoLineItem new Po will generate on the invoice date.") == true) {
|
|
|
676 |
|
|
|
677 |
doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id, function(response) {
|
|
|
678 |
if (response == 'true') {
|
|
|
679 |
getGrnRequestItems(requestId, invoiceId)
|
|
|
680 |
}
|
|
|
681 |
});
|
|
|
682 |
|
|
|
683 |
}
|
|
|
684 |
}
|
|
|
685 |
|
|
|
686 |
});
|
|
|
687 |
|
|
|
688 |
|
|
|
689 |
|
|
|
690 |
$(document).on('click', '.resolvedQtyMismatchRequest', function() {
|
|
|
691 |
var id = $(this).data("id");
|
|
|
692 |
|
|
|
693 |
var invoiceId = $(this).data("invoiceid");
|
|
|
694 |
|
|
|
695 |
var requestId = $(this).data("requestid");
|
|
|
696 |
var requestId = $(this).data("requestid");
|
|
|
697 |
|
|
|
698 |
|
| 32261 |
tejbeer |
699 |
var mismatch = $(this).data("mismatch");
|
| 32256 |
tejbeer |
700 |
|
|
|
701 |
var $row = $(this).closest("tr");
|
|
|
702 |
var requiredQty = $row.find(".requiredQty").val();
|
|
|
703 |
|
|
|
704 |
console.log(requiredQty);
|
|
|
705 |
|
| 32261 |
tejbeer |
706 |
if (mismatch == "QtyMismatch") {
|
| 32256 |
tejbeer |
707 |
if (confirm("Are you sure you want to resolve qty mismatch") == true) {
|
|
|
708 |
|
|
|
709 |
doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id + "&requiredQty=" + requiredQty, function(response) {
|
|
|
710 |
if (response == 'true') {
|
|
|
711 |
getGrnRequestItems(requestId, invoiceId)
|
|
|
712 |
}
|
|
|
713 |
});
|
|
|
714 |
|
|
|
715 |
}
|
|
|
716 |
}
|
|
|
717 |
|
|
|
718 |
});
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
|
| 32145 |
tejbeer |
724 |
});
|
|
|
725 |
|
|
|
726 |
function loadCreatePurchase(domId) {
|
|
|
727 |
doGetAjaxRequestHandler(context + "/warehousePurchaseOrder", function(response) {
|
|
|
728 |
$('#' + domId).html(response);
|
|
|
729 |
});
|
|
|
730 |
}
|
|
|
731 |
|
| 32192 |
tejbeer |
732 |
|
|
|
733 |
|
| 32145 |
tejbeer |
734 |
function loadOpenPurchase(domId) {
|
|
|
735 |
|
|
|
736 |
doGetAjaxRequestHandler(context + "/getOpenPurchaseOrder", function(response) {
|
|
|
737 |
$('#' + domId).html(response);
|
|
|
738 |
});
|
|
|
739 |
}
|
|
|
740 |
|
| 32192 |
tejbeer |
741 |
function loadNewReceiveInvoice(domId) {
|
|
|
742 |
doGetAjaxRequestHandler(context + "/newReceiveInvoice", function(response) {
|
|
|
743 |
$('#' + domId).html(response);
|
|
|
744 |
});
|
|
|
745 |
}
|
|
|
746 |
|
| 32256 |
tejbeer |
747 |
|
|
|
748 |
|
|
|
749 |
function loadGrnRequest(domId) {
|
|
|
750 |
doGetAjaxRequestHandler(context + "/grnRequest", function(response) {
|
|
|
751 |
$('#' + domId).html(response);
|
|
|
752 |
});
|
|
|
753 |
}
|
|
|
754 |
|
|
|
755 |
function loadDebitNote(domId) {
|
|
|
756 |
doGetAjaxRequestHandler(context + "/getDebitNote", function(response) {
|
|
|
757 |
$('#' + domId).html(response);
|
|
|
758 |
});
|
|
|
759 |
}
|
|
|
760 |
|
| 32300 |
tejbeer |
761 |
function loadWarehouseInvoices(domId) {
|
|
|
762 |
doGetAjaxRequestHandler(context + "/getWarehouseInvoices", function(response) {
|
|
|
763 |
$('#' + domId).html(response);
|
|
|
764 |
});
|
|
|
765 |
}
|
|
|
766 |
|
| 32145 |
tejbeer |
767 |
function createPurchase(sendPo) {
|
|
|
768 |
var purchaseOrder = {};
|
|
|
769 |
|
|
|
770 |
var vendorId = $('#vendorId').val();
|
|
|
771 |
|
|
|
772 |
var warehouseId = $('#warehouseMap').val();
|
|
|
773 |
|
|
|
774 |
|
|
|
775 |
var items = []
|
|
|
776 |
$("table > tbody > tr").each(function() {
|
|
|
777 |
var purchaseOrderJson = {};
|
|
|
778 |
|
|
|
779 |
var itemId = $(this).find(".transferPrice").data('itemid');
|
|
|
780 |
var qty = $(this).find(".qty").val();
|
|
|
781 |
var transferPrice = $(this).find(".transferPrice").val();
|
|
|
782 |
var totalValue = $(this).find(".totalValue").val();
|
|
|
783 |
|
|
|
784 |
|
|
|
785 |
purchaseOrderJson['itemId'] = itemId;
|
| 32256 |
tejbeer |
786 |
purchaseOrderJson['amendedQty'] = qty
|
| 32145 |
tejbeer |
787 |
purchaseOrderJson['totalValue'] = totalValue
|
|
|
788 |
purchaseOrderJson['transferPrice'] = transferPrice
|
|
|
789 |
|
|
|
790 |
items.push(purchaseOrderJson)
|
|
|
791 |
});
|
|
|
792 |
|
|
|
793 |
|
|
|
794 |
for (var i = 0; i < items.length; i++) {
|
|
|
795 |
console.log(items[i])
|
|
|
796 |
|
|
|
797 |
var itemId = items[i].itemId
|
| 32261 |
tejbeer |
798 |
var qty = items[i].amendedQty
|
| 32145 |
tejbeer |
799 |
var transferPrice = items[i].transferPrice
|
|
|
800 |
var totalValue = items[i].totalValue
|
|
|
801 |
|
|
|
802 |
if (itemId === "" && qty === "" && transferPrice === "" && totalValue === "") {
|
|
|
803 |
alert("Field can't be empty");
|
|
|
804 |
return false;
|
|
|
805 |
}
|
|
|
806 |
|
|
|
807 |
|
|
|
808 |
if (itemId === "") {
|
|
|
809 |
alert("please select item");
|
|
|
810 |
return false;
|
|
|
811 |
}
|
|
|
812 |
if (qty === "") {
|
|
|
813 |
alert("please choose qty");
|
|
|
814 |
return false;
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
if (transferPrice === "") {
|
|
|
818 |
alert("Transfer Price can't be empty");
|
|
|
819 |
return false;
|
|
|
820 |
}
|
|
|
821 |
if (totalValue === "") {
|
|
|
822 |
alert("Total value can't be empty");
|
|
|
823 |
return false;
|
|
|
824 |
}
|
|
|
825 |
|
| 32261 |
tejbeer |
826 |
if (qty <= 0) {
|
|
|
827 |
alert("Please fill Qty");
|
|
|
828 |
return false;
|
|
|
829 |
}
|
| 32145 |
tejbeer |
830 |
|
|
|
831 |
|
| 32261 |
tejbeer |
832 |
|
| 32145 |
tejbeer |
833 |
}
|
|
|
834 |
|
|
|
835 |
purchaseOrder['vendorId'] = vendorId;
|
|
|
836 |
purchaseOrder['warehouseId'] = warehouseId
|
|
|
837 |
purchaseOrder['sendPo'] = sendPo
|
|
|
838 |
|
|
|
839 |
purchaseOrder['items'] = items
|
|
|
840 |
|
|
|
841 |
console.log(purchaseOrder)
|
|
|
842 |
|
|
|
843 |
|
|
|
844 |
|
|
|
845 |
if (confirm("Are you sure you want to create purchase order") == true) {
|
|
|
846 |
|
|
|
847 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
848 |
+ "/createPurchaseOrder", JSON
|
|
|
849 |
.stringify(purchaseOrder), function(response) {
|
|
|
850 |
if (response == 'true') {
|
|
|
851 |
alert("successfully created");
|
| 32256 |
tejbeer |
852 |
loadCreatePurchase("main-content");
|
| 32145 |
tejbeer |
853 |
}
|
|
|
854 |
});
|
|
|
855 |
}
|
|
|
856 |
|
|
|
857 |
}
|
|
|
858 |
|
|
|
859 |
|
|
|
860 |
function editPurchase(sendPo, poid) {
|
|
|
861 |
var editpurchaseOrder = {}
|
|
|
862 |
var items = []
|
|
|
863 |
$("#purchase-edit-lineitem > tbody > tr").each(function() {
|
|
|
864 |
var purchaseOrderJson = {};
|
|
|
865 |
var itemId = $(this).find("td:eq(0)").text();
|
|
|
866 |
|
| 32256 |
tejbeer |
867 |
var qty = $(this).find("td:eq(2)").text();
|
| 32145 |
tejbeer |
868 |
|
| 32256 |
tejbeer |
869 |
var amendedQty = $(this).find(".editqty").val();
|
|
|
870 |
|
| 32283 |
tejbeer |
871 |
var transferPrice = $.trim($(this).find(".transferPrice").html());
|
| 32256 |
tejbeer |
872 |
|
|
|
873 |
|
| 32145 |
tejbeer |
874 |
purchaseOrderJson['itemId'] = itemId;
|
| 32256 |
tejbeer |
875 |
purchaseOrderJson['amendedQty'] = parseInt(amendedQty)
|
|
|
876 |
purchaseOrderJson['qty'] = parseInt(qty)
|
| 32282 |
tejbeer |
877 |
purchaseOrderJson['transferPrice'] = transferPrice
|
| 32145 |
tejbeer |
878 |
|
|
|
879 |
items.push(purchaseOrderJson)
|
|
|
880 |
});
|
|
|
881 |
|
|
|
882 |
|
|
|
883 |
for (var i = 0; i < items.length; i++) {
|
|
|
884 |
console.log(items[i])
|
|
|
885 |
|
| 32256 |
tejbeer |
886 |
var amendedQty = items[i].amendedQty
|
| 32145 |
tejbeer |
887 |
var qty = items[i].qty
|
|
|
888 |
|
| 32256 |
tejbeer |
889 |
|
|
|
890 |
if (amendedQty === "") {
|
| 32145 |
tejbeer |
891 |
alert("please choose qty");
|
|
|
892 |
return false;
|
|
|
893 |
}
|
|
|
894 |
|
| 32256 |
tejbeer |
895 |
if (amendedQty < qty) {
|
|
|
896 |
alert("Quantity should be greater than existing qty");
|
| 32145 |
tejbeer |
897 |
return false;
|
|
|
898 |
}
|
|
|
899 |
|
|
|
900 |
|
|
|
901 |
}
|
|
|
902 |
|
|
|
903 |
editpurchaseOrder['purchaseOrderId'] = poid;
|
|
|
904 |
editpurchaseOrder['sendPo'] = sendPo
|
|
|
905 |
editpurchaseOrder['items'] = items
|
|
|
906 |
|
|
|
907 |
|
|
|
908 |
if (confirm("Are you sure you want to edit purchase order") == true) {
|
|
|
909 |
|
|
|
910 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
911 |
+ "/editPurchaseOrder", JSON
|
|
|
912 |
.stringify(editpurchaseOrder), function(response) {
|
|
|
913 |
if (response == 'true') {
|
|
|
914 |
alert("successfully created");
|
| 32295 |
tejbeer |
915 |
$('#warehouseEditPurchaseContainer').modal('hide');
|
|
|
916 |
$('.modal-backdrop').remove();
|
|
|
917 |
|
| 32256 |
tejbeer |
918 |
loadOpenPurchase("main-content")
|
| 32145 |
tejbeer |
919 |
}
|
|
|
920 |
});
|
|
|
921 |
}
|
|
|
922 |
|
|
|
923 |
}
|
|
|
924 |
|
|
|
925 |
|
| 32192 |
tejbeer |
926 |
function getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, validate) {
|
|
|
927 |
|
|
|
928 |
var invoiceJson = {};
|
|
|
929 |
console.log(numItems)
|
|
|
930 |
var totalQty = 0;
|
|
|
931 |
var invoiceItems = []
|
|
|
932 |
$("#invoice-order-table > tbody > tr").each(function() {
|
|
|
933 |
var invoiceItemJson = {};
|
|
|
934 |
var itemId = $(this).find(".rate").data('itemid');
|
|
|
935 |
var qty = $(this).find(".qty").val();
|
|
|
936 |
|
|
|
937 |
if (qty != undefined) {
|
|
|
938 |
totalQty += parseInt(qty)
|
|
|
939 |
}
|
|
|
940 |
var rate = $(this).find(".rate").val();
|
|
|
941 |
invoiceItemJson['itemId'] = itemId;
|
|
|
942 |
invoiceItemJson['qty'] = qty
|
|
|
943 |
invoiceItemJson['rate'] = rate
|
|
|
944 |
invoiceItems.push(invoiceItemJson)
|
|
|
945 |
});
|
|
|
946 |
|
|
|
947 |
|
|
|
948 |
for (var i = 0; i < invoiceItems.length; i++) {
|
|
|
949 |
|
|
|
950 |
var itemId = invoiceItems[i].itemId
|
|
|
951 |
var qty = invoiceItems[i].qty
|
|
|
952 |
var rate = invoiceItems[i].rate
|
|
|
953 |
if (itemId === "" && qty === "" && rate === "") {
|
|
|
954 |
alert("Field can't be empty");
|
|
|
955 |
return false;
|
|
|
956 |
}
|
|
|
957 |
|
|
|
958 |
if (itemId === "") {
|
|
|
959 |
alert("please select item");
|
|
|
960 |
return false;
|
|
|
961 |
}
|
|
|
962 |
if (qty === "") {
|
|
|
963 |
alert("please choose qty");
|
|
|
964 |
return false;
|
|
|
965 |
}
|
|
|
966 |
|
|
|
967 |
if (rate === "") {
|
|
|
968 |
alert("Rate can't be empty");
|
|
|
969 |
return false;
|
|
|
970 |
}
|
|
|
971 |
|
|
|
972 |
}
|
|
|
973 |
|
|
|
974 |
console.log(totalQty)
|
|
|
975 |
|
|
|
976 |
if (totalQty > numItems) {
|
|
|
977 |
alert("Qty Should not be more than Invoice items");
|
|
|
978 |
return false;
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
if (validate) {
|
|
|
982 |
|
|
|
983 |
if (totalQty != numItems) {
|
|
|
984 |
alert("Qty Should not match with Invoice items");
|
|
|
985 |
return false;
|
|
|
986 |
}
|
|
|
987 |
}
|
|
|
988 |
|
|
|
989 |
|
|
|
990 |
invoiceJson['invoiceId'] = invoiceId;
|
|
|
991 |
invoiceJson['warehouseId'] = warehouseId;
|
|
|
992 |
invoiceJson['supplierId'] = supplierId;
|
|
|
993 |
invoiceJson['invoiceItems'] = invoiceItems
|
|
|
994 |
if (validate) {
|
|
|
995 |
validateInvoiceItems(invoiceJson);
|
|
|
996 |
} else {
|
|
|
997 |
saveInvoiceItems(invoiceJson)
|
|
|
998 |
}
|
|
|
999 |
}
|
|
|
1000 |
|
|
|
1001 |
|
|
|
1002 |
function saveInvoiceItems(invoiceJson) {
|
|
|
1003 |
|
|
|
1004 |
|
|
|
1005 |
if (confirm("Are you sure you want to save invoice item") == true) {
|
|
|
1006 |
|
|
|
1007 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
1008 |
+ "/invoiceItemDetail", JSON
|
|
|
1009 |
.stringify(invoiceJson), function(response) {
|
|
|
1010 |
if (response == 'true') {
|
|
|
1011 |
getInvoiceItems(invoiceJson.invoiceId);
|
|
|
1012 |
}
|
|
|
1013 |
});
|
|
|
1014 |
}
|
|
|
1015 |
|
|
|
1016 |
}
|
|
|
1017 |
|
|
|
1018 |
|
|
|
1019 |
function validateInvoiceItems(invoiceJson) {
|
|
|
1020 |
|
|
|
1021 |
|
|
|
1022 |
if (confirm("Are you sure you want to validate invoice item") == true) {
|
|
|
1023 |
|
|
|
1024 |
doPostAjaxRequestWithJsonHandler(context
|
|
|
1025 |
+ "/validateInvoiceItemDetail", JSON
|
|
|
1026 |
.stringify(invoiceJson), function(response) {
|
|
|
1027 |
$('.invoiceadditemcontainer').html(response);
|
|
|
1028 |
|
|
|
1029 |
});
|
|
|
1030 |
}
|
|
|
1031 |
|
|
|
1032 |
}
|
|
|
1033 |
|
|
|
1034 |
function getOpenPOFromWarehouse() {
|
|
|
1035 |
|
|
|
1036 |
var warehouseId = $('#warehouseMap').val();
|
|
|
1037 |
doGetAjaxRequestHandler(context + "/getOpenPurchaseOrderByWarehouseId?warehouseId=" + warehouseId, function(response) {
|
|
|
1038 |
$('#warehouseManagePuchaseContainer').html(response);
|
|
|
1039 |
});
|
|
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
|
|
|
1043 |
}
|
|
|
1044 |
|
|
|
1045 |
function getPurchaseLineitem(poId) {
|
|
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
doGetAjaxRequestHandler(context + "/getPurchaseOrderItemByPoId?poId=" + poId, function(response) {
|
|
|
1049 |
$('#warehouseManagePuchaseItemContainer').html(response);
|
|
|
1050 |
$('#warehousepurchaseitemgrn').hide()
|
|
|
1051 |
});
|
|
|
1052 |
|
|
|
1053 |
|
|
|
1054 |
}
|
|
|
1055 |
|
|
|
1056 |
|
|
|
1057 |
function getInvoiceItems(invoiceId) {
|
|
|
1058 |
|
|
|
1059 |
doGetAjaxRequestHandler(context + "/getInvoiceItems?invoiceId=" + invoiceId, function(response) {
|
|
|
1060 |
$('.invoiceadditemcontainer').html(response);
|
|
|
1061 |
|
|
|
1062 |
});
|
|
|
1063 |
}
|
|
|
1064 |
|
|
|
1065 |
|
| 32256 |
tejbeer |
1066 |
function getGrnRequestItems(requestId, invoiceId) {
|
|
|
1067 |
|
|
|
1068 |
doGetAjaxRequestHandler(context + "/grnRequestItem?requestId=" + requestId + "&invoiceId=" + invoiceId, function(response) {
|
|
|
1069 |
$('.grnRequestItemContainer').html(response);
|
|
|
1070 |
|
|
|
1071 |
});
|
|
|
1072 |
}
|
|
|
1073 |
|
|
|
1074 |
|