Sales Invoice Showing Qty

Good Afternoon,

Can i have my sales Invoice show my available qty when item is scanned on the sales invoice.

How can i achieve this?

Hey @kolotayo, to do so, please…

Place a custom field to display the data in the Sales Invoice Item Form.

  1. Use the Customize Form and search for the DocType Sales Invoice Item
  2. Then add a field called qty_in_stock (it could be any name) and we recomend to make it the read only
  3. Additionally you can set to show in the list view, but will need to remove one of the existing fields.

After you finish that out you can create a new Custom Script for the doctype Sales Invoice and copy and paste the following code:

frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) {
	var row = frappe.get_doc(cdt, cdn);

	frappe.call({
		"method": "frappe.client.get_value",
		"args": {
			"doctype": "Stock Ledger Entry",
			"filters": {
				"item_code": row.item_code,
				"warehouse": row.warehouse
			},
			"fieldname": ["sum(actual_qty) qty"],
		},
		"callback": function(response) {
			var r = response.message;

			if (r && r.qty) {
				frappe.model.set_value(cdt, cdn, "qty_in_stock", r.qty);
			}
		}
	})
})

Thank You this works perfectly

But the issue i have about it now is that The Filed is showing and available but the Stock Qty is not showing anything.

Any help please?

Thats is what i got