fix: fetch overdue payments

This commit is contained in:
barredterra 2021-11-13 01:39:22 +01:00 committed by marination
parent 8bfe865759
commit 60b6afb470
2 changed files with 7 additions and 2 deletions

View File

@ -49,10 +49,11 @@ frappe.ui.form.on("Dunning", {
}
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 @@ frappe.ui.form.on("Dunning", {
status: "Overdue",
company: frm.doc.company
},
allow_child_item_selection: true,
child_fielname: "payment_schedule",
child_columns: ["due_date", "outstanding"],
});
});
}

View File

@ -2516,7 +2516,7 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False):
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 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False):
return get_mapped_doc(
from_doctype="Sales Invoice",
from_docname=source_name,
target_doc=target_doc,
table_maps={
"Sales Invoice": {
"doctype": "Dunning",