Mandatory fields error in New Sales Invoice created from js

I am trying to redirect user to new sales invoice form with item details from another custom doc. Are these item details sufficient to create the invoice?

		let invoice = frappe.model.get_new_doc("Sales Invoice");
		invoice.naming_series = "SINV-";

		for (let d of frm.doc.items) {
			let invoice_item = frappe.model.add_child(invoice, "items")
			invoice_item.item_code = d.item;
			invoice_item.qty = d.qty;
			invoice_item.rate = d.rate;
		frappe.set_route("Form", invoice.doctype,;

I am getting error for mandatory fields on saving the invoice, I thought these would be picked up from defaults like when selecting items manually on the Sales Invoice Form.

I have a suspicion this used to work before, does anyone know if this worked before?