Subversion Repositories SmartDukaan

Rev

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

Rev 32627 Rev 32816
Line 350... Line 350...
350
        var $el = $(el);
350
        var $el = $(el);
351
        var $unitPriceElement = $el.find('.unitPrice');
351
        var $unitPriceElement = $el.find('.unitPrice');
352
        var itemId = parseInt($unitPriceElement.attr("itemId"));
352
        var itemId = parseInt($unitPriceElement.attr("itemId"));
353
        var qty = parseInt($unitPriceElement.attr("quantity"));
353
        var qty = parseInt($unitPriceElement.attr("quantity"));
354
        var found = false;
354
        var found = false;
-
 
355
            var customSerialNumberEl = $(el).find('.customSerialNumber');
355
        let tmpObj;
356
        let tmpObj;
356
        let filteredList = priceQtyArray.filter(x => x.itemId === itemId);
357
        let filteredList = priceQtyArray.filter(x => x.itemId === itemId);
357
        if (filteredList.length === 0) {
358
        if (filteredList.length === 0) {
358
            var $discountElement = $el.find('.discount');
359
            var $discountElement = $el.find('.discount');
359
            var unitPrice = parseFloat($unitPriceElement.val());
360
            var unitPrice = parseFloat($unitPriceElement.val());
360
            var discount = parseFloat($discountElement.val());
361
            var discount = parseFloat($discountElement.val());
361
            if (isNaN(discount)) {
362
            if (isNaN(discount)) {
362
                discount = 0;
363
                discount = 0;
363
            }
364
            }
-
 
365
            let customSerialNumbers = [];
-
 
366
 
-
 
367
            if (customSerialNumberEl.val() !== '') {
-
 
368
                customSerialNumbers = customSerialNumberEl.val().split(",").map(function (serial) {
-
 
369
                    return serial.trim(); // Trim spaces from each serial number
-
 
370
                });
-
 
371
 
-
 
372
                if (customSerialNumbers.length !== qty) {
-
 
373
                    alert("Please add all serial numbers");
-
 
374
                    return false;
-
 
375
                }
-
 
376
            }
-
 
377
 
364
            tmpObj = {
378
            tmpObj = {
365
                itemId: itemId,
379
                itemId: itemId,
366
                sellingPrice: unitPrice - discount,
380
                sellingPrice: unitPrice - discount,
367
                quantity: 0,
381
                quantity: 0,
368
                discountAmount: discount,
382
                discountAmount: discount,
-
 
383
                customSerialNumbers: customSerialNumberEl.val().split(","),
369
                serialNumberDetails: []
384
                serialNumberDetails: []
370
            };
385
            };
-
 
386
 
371
            priceQtyArray.push(tmpObj);
387
            priceQtyArray.push(tmpObj);
372
        } else {
388
        } else {
373
            tmpObj = filteredList[0];
389
            tmpObj = filteredList[0];
374
        }
390
        }
375
 
391
 
376
        tmpObj.quantity += qty;
392
            tmpObj.quantity += qty;
377
 
393
 
378
        var $serialNumberElement = $(el).find('.serialNumber');
394
            var $serialNumberElement = $(el).find('.serialNumber');
379
        var insuranceEle = $(el).find('.insuranceamount');
395
            var insuranceEle = $(el).find('.insuranceamount');
380
        var insuranceAmount = 0;
396
            var insuranceAmount = 0;
381
        if (insuranceEle.length > 0) {
397
            if (insuranceEle.length > 0) {
382
            insuranceAmount = parseFloat(insuranceEle.val());
398
                insuranceAmount = parseFloat(insuranceEle.val());
383
        }
399
            }
384
        var insuranceId = "";
400
            var insuranceId = "";
385
        if (insuranceAmount > 0) {
401
            if (insuranceAmount > 0) {
386
            insuranceId = $(el).find('.insuranceid').val();
402
                insuranceId = $(el).find('.insuranceid').val();
387
        }
403
            }
388
        var ram = $(el).find('.ram').val();
404
            var ram = $(el).find('.ram').val();
389
        var memory = $(el).find('.memory').val();
405
            var memory = $(el).find('.memory').val();
390
        var mfgdate = $(el).find('.mfgdate').val();
406
            var mfgdate = $(el).find('.mfgdate').val();
391
        var serialNumberDetail = {
407
            var serialNumberDetail = {
392
            'serialNumber': $serialNumberElement.val(), 'insurance': insuranceId, 'amount': insuranceAmount,
408
                'serialNumber': $serialNumberElement.val(), 'insurance': insuranceId, 'amount': insuranceAmount,
393
            'ram': ram, 'memory': memory, 'mfgDate': mfgdate
409
                'ram': ram, 'memory': memory, 'mfgDate': mfgdate
394
        };
410
            };
395
        tmpObj.serialNumberDetails.push(serialNumberDetail);
411
            tmpObj.serialNumberDetails.push(serialNumberDetail);
396
 
412
 
-
 
413
        }
-
 
414
    )
397
    });
415
    ;
398
 
416
 
399
 
417
 
400
    customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
418
    customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
401
    if (customerId == undefined) {
419
    if (customerId == undefined) {
402
        alert("Please choose customer");
420
        alert("Please choose customer");
Line 405... Line 423...
405
    if ($("#customer-address").data("addressselected") == "true") {
423
    if ($("#customer-address").data("addressselected") == "true") {
406
        alert("Please select address");
424
        alert("Please select address");
407
        return false;
425
        return false;
408
    }
426
    }
409
    customerObj['customerId'] = customerId;
427
    customerObj['customerId'] = customerId;
410
    // Check if selectedAddressId is defined and not empty
428
// Check if selectedAddressId is defined and not empty
411
    if (typeof selectedAddressId !== "undefined" && selectedAddressId !== null && selectedAddressId !== "") {
429
    if (typeof selectedAddressId !== "undefined" && selectedAddressId !== null && selectedAddressId !== "") {
412
        customerObj['customerAddressId'] = selectedAddressId;
430
        customerObj['customerAddressId'] = selectedAddressId;
413
    } else {
431
    } else {
414
        customerObj['customerAddressId'] = null;
432
        customerObj['customerAddressId'] = null;
415
    }
433
    }
Line 417... Line 435...
417
    customerObj['gender'] = $("#gender").val();
435
    customerObj['gender'] = $("#gender").val();
418
    customerObj['dateOfBirth'] = getDatesFromPicker("#dateOfBirth").startDate;
436
    customerObj['dateOfBirth'] = getDatesFromPicker("#dateOfBirth").startDate;
419
 
437
 
420
 
438
 
421
    var paymentOptionSize = parseInt($('#payment-option-id-amount-container').attr("paymentOptionSize"));
439
    var paymentOptionSize = parseInt($('#payment-option-id-amount-container').attr("paymentOptionSize"));
422
    // console.log("paymentOptionSize = "+paymentOptionSize);
440
// console.log("paymentOptionSize = "+paymentOptionSize);
423
    for (var index = 0; index < paymentOptionSize; index++) {
441
    for (var index = 0; index < paymentOptionSize; index++) {
424
        var paymentOptionAmount = 0.0;
442
        var paymentOptionAmount = 0.0;
425
        if ($('#paymentOptionIdAmount' + index).val() != "") {
443
        if ($('#paymentOptionIdAmount' + index).val() != "") {
426
            paymentOptionAmount = parseFloat($('#paymentOptionIdAmount' + index).val());
444
            paymentOptionAmount = parseFloat($('#paymentOptionIdAmount' + index).val());
427
        }
445
        }