Language: JavaScript
Label: safe
CWE: CWE-829 \u2014 Inclusion of Functionality from Untrusted Control Sphere
The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.

Code:
      unit: $(selector).closest("tr").find(".productItemUnit").val()
    }, product => {

      if(product["error"] !== undefined && product["error"] === true) {

        $(that).val(product.stq); // Set the product quantity with Stock Quantity
        Quantity = product.stq;

        // Display the error message
        Swal.fire({
            title: "Error!",
            text: product["msg"],
            icon: "error"
        });

      }

      // Check if product[0] isset, if not the use direct product
      // Because If there is any error then the product details come with the error
      var product = product[0] ? product[0] : product;

      // change product background color while changing qty and when out of stock
      if(product.so) {

        $(selector).closest("tr").css("background-color", "pink");

      } else {

        $(selector).closest("tr").css("background-color", "white");

      }

      // Display Subtotal for each product
      $(SubtotalRow).html((BMS.FUNCTIONS.calculateDiscount(netSalesPrice,Discount) * Quantity).toFixed(2));

      // Update the packet
      var packet = 0;
      if(Number(product.pq) > 0) {
        packet = (Quantity / Number(product.pq)).toFixed(2);
      }
      packetSelector.val( packet );

      // Call the grand total
      this.grandTotal();
    
    });

  },