Subversion Repositories SmartDukaan

Rev

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

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