Calculate item table value if quantity is less than 1

Hi i am new to script i want to calculate total packing charges if the quantity is less than 1 or negative(eg: -2,-4,-5)

frappe.ui.form.on(“Sales Invoice Item”, {
qty: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
if (row.qty < 0)
{
frappe.model.set_value(cdt, cdn, ‘total_packing_charges’, (d.qty * d.packing_charges*-1));
console.log(“message”);
frm.refresh_field(‘Sales Invoice Item’);
}
}
});

this is my code to calculate it when the value is positive.
Please help

added if condition later to calculate negative but that is not working.

row is not defined so please use d.

like

if (d.qty < 0)

// or

if (d.qty > 0)

Please set your condition according.

Thank You!