fix: fetch overdue payments
diff --git a/erpnext/accounts/doctype/dunning/dunning.js b/erpnext/accounts/doctype/dunning/dunning.js
index 99b408a..c2b9169 100644
--- a/erpnext/accounts/doctype/dunning/dunning.js
+++ b/erpnext/accounts/doctype/dunning/dunning.js
@@ -49,10 +49,11 @@
 		}
 
 		if (frm.doc.docstatus === 0) {
-			frm.add_custom_button(__("Fetch Overdue Payments"), function () {
+			frm.add_custom_button(__("Fetch Overdue Payments"), () => {
 				erpnext.utils.map_current_doc({
 					method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
 					source_doctype: "Sales Invoice",
+					date_field: "due_date",
 					target: frm,
 					setters: {
 						customer: frm.doc.customer || undefined,
@@ -62,6 +63,9 @@
 						status: "Overdue",
 						company: frm.doc.company
 					},
+					allow_child_item_selection: true,
+					child_fielname: "payment_schedule",
+					child_columns: ["due_date", "outstanding"],
 				});
 			});
 		}
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index f8f7c36..3cce388 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -2516,7 +2516,7 @@
 	def postprocess_dunning(source, target):
 		from erpnext.accounts.doctype.dunning.dunning import get_dunning_letter_text
 
-		dunning_type = frappe.db.exists("Dunning Type", {"is_default": 1})
+		dunning_type = frappe.db.exists("Dunning Type", {"is_default": 1, "company": source.company})
 		if dunning_type:
 			dunning_type = frappe.get_doc("Dunning Type", dunning_type)
 			target.dunning_type = dunning_type.name
@@ -2538,6 +2538,7 @@
 	return get_mapped_doc(
 		from_doctype="Sales Invoice",
 		from_docname=source_name,
+		target_doc=target_doc,
 		table_maps={
 			"Sales Invoice": {
 				"doctype": "Dunning",